That is to bad. I have a project that I use mongodb and mongotools and I can do the following with one form and it works great. I wonder if any other form tools can do it
class UserForm ( MongoForm ): class Meta: document = User fields = ('first_name','last_name') class ProfileForm ( UserForm ): class Meta(UserForm.Meta): document = Profile On Dec 4, 11:56 am, akaariai <akaar...@gmail.com> wrote: > On Dec 4, 6:05 pm,CrabbyPete<pete.do...@gmail.com> wrote: > > > > > > > > > > > I wanted to combine two models into one form so I created the > > following > > > class UserForm( ModelForm ): > > class Meta: > > model = User > > fields = ('email','first_name','last_name') > > > class ProfileForm( ModelForm ): > > class Meta: > > model = Profile > > > class UserProfile ( UserForm, ProfileForm ) > > class Meta( UserForm.Meta, ProfileForm.Meta) > > exclude = ('user',) > > > It only inherits UserForm > > > Is there a way to create one form using 2 modelform or to have > > ProfileForm inherit from UserForm and add > > Profile form data. Something like this > > I don't think that is possible. > > You will need to use both forms separately, and if you need combined > validation or something like that, then do that in your view code. You > can create a wrapper class which behaves mostly like a form, but > delegates the actions to the two underlying forms. (eg is_valid(): > return form1.is_valid() and form2.is_valid()). Making it behave > exactly like a single form will be hard. > > - Anssi -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.