Muliple Models in a single django ModelForm?
Posted
by BigJason
on Stack Overflow
See other posts from Stack Overflow
or by BigJason
Published on 2010-05-05T05:23:34Z
Indexed on
2010/05/05
5:28 UTC
Read the original article
Hit count: 208
django
|django-forms
Is it possible to have multiple models included in a single ModelForm
in django? I am trying to create a profile edit form. So I need to include some fields from the User model and the UserProfile model. Currently I am using 2 forms like this
class UserEditForm(ModelForm):
class Meta:
model = User
fields = ("first_name", "last_name")
class UserProfileForm(ModelForm):
class Meta:
model = UserProfile
fields = ("middle_name", "home_phone", "work_phone", "cell_phone")
Is there a way to consolidate these into one form or do I just need to create a form and handle the db loading and saving myself?
© Stack Overflow or respective owner