0

私は次の方法でモデルを使用しています:

class UserProfile:
# Some Stuff

class CompanyProfile(UserProfile):
# Some more stuff

class CandidateProfile(UserProfile):
# Even more stuff

CompanyProfile と CandidateProfile が UserProfile から継承していることを意味します。これらの CompanyProfile と CandidateProfile を登録フォームと別のプロファイルフォームから入力するにはどうすればよいですか? ユーザーを作成したり、データを入力したりしているプロファイルをどのように伝えることができますか?

4

1 に答える 1

0

ここのstackoverflow.comの別のスレッドにある次の方法でそれを行いました: django user profile creation,set user profile while using multiple profile types、コードは次のとおりです:

def save(self, commit=True):
user = super(UserRegistrationForm, self).save(commit=False)
user.email = self.cleaned_data["email"]
if commit:
    user.save()
    person = Person(user=user)
    person.full_name = self.cleaned_data["fullname"]
    person.save()
return user
于 2012-06-24T12:11:45.487 に答える