Thursday, September 26, 2013

Re: How to do 2-ModelForm-in-1-CVB right?

Inlineformset may solve your problem, and this is a good example.

在 2013年9月26日星期四UTC+8下午1时19分41秒,Adam写道:

I am trying to handle 2 ModelForm in 1 view. Is that possible with CBV solution? Does any best practise exist?

Here is the problem in details.


class UserProfile(HasJPAddresses, models.Model):

    user = models.OneToOneField(User)
    birthdate = models.DateField(default='1900-01-01')


class UserProfileUpdateForm(forms.ModelForm):
    class Meta:
        model = UserProfile

class UserUpdateForm(forms.ModelForm):
    class Meta:
        model = User
        fields = ['first_name', 'last_name']


class UserProfileUpdateView(FormView): <<<<<<<---- How could I handle two forms at once in a view?


You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

No comments:

Post a Comment