Hello all,

A situation that I'm encountering all the more often is something like  
this: You create a form that has some fields that belong to one model,  
and some fields from another model. Because it's a mix, you can't make  
it as easy as a ModelForm. I love ModelForms. :-)

One common example of this is if you want to change user information,  
and you have a UserProfile -- you may want to change both the User and  
its associated UserProfile.

Ideally, the MixModelForm class would work something like this:

1) It would allow you to specify fields from different models that you  
want to "import" into this form
2) It would validate based on those fields, of course
3) Finally, if everything validates fine, it would take care of saving  
the data in all the right places

So what are your ways of dealing with this situation?

I actually started working on this kind of form class, but got lost in  
metaclass hell. And I'm worried that I'd run into problems if I'm  
starting to override django Form classes, since metaclasses and this  
style of programming is relatively new for me.

If anyone is interested, I have created an AdaptiveField(model, field,  
**kwargs) that accomplishes #1 and #2, but you still have to care of  
saving yourself (#3).

I would love any ideas or feedback around this area, and to hear of  
how others in the community do it.

/Håkan
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to