djangoのユーザーモデルを拡張して、場所や雇用者など、他のいくつかの変数を含めました。今、私は次のフィールドを持つフォームを作成しようとしています:
First name (from User)
Last name (from User)
Location (from UserProfile, which extends User via a foreign key)
Employer (also from UserProfile)
モデルフォームを作成しました:
from django.forms import ModelForm
from django.contrib import auth
from alert.userHandling.models import UserProfile
class ProfileForm(ModelForm):
class Meta:
# model = auth.models.User # this gives me the User fields
model = UserProfile # this gives me the UserProfile fields
それで、私の質問は、ユーザーモデルまたはUserProfileモデルのどちらからのものであるかにかかわらず、すべてのフィールドにアクセスできるModelFormを作成するにはどうすればよいですか?
これが理にかなっていることを願っています。ご不明な点がございましたら、お気軽にお問い合わせください。