On Mon, Sep 22, 2008 at 8:57 AM, diN0bot <[EMAIL PROTECTED]> wrote:
>
> Seems like Joseph's problem is typical for User/Profile work.
>
> Initially I used the same inheritance model as he does. Working with a
> single form in the view and template is a win for code re-use and
> simplicity.
>
> I looked into formsets but haven't gotten it to work with multiple
> model types. It seems like I should be able to show the User form with
> the Profile inlined, right?

No. Formsets are designed to work with instances of a single model
type. Inline formsets are closer to what you want, but really, that
adds a lot more complication that just writing 2 forms would. Even if
you *do* use an inline formset, you're still going to have to render
both the form and the formset.

> My solution is to create a class that generalizes working with
> multiple model forms. Or rather, it abstract the multiple form
> handling and printing behind a Form interface so that the view and
> template don't know the difference. It'd be nice to make more use of
> formsets or provided code since I feel like I've reinvented the wheel.

You aren't reinventing the wheel. There isn't code in Django to do
what you're trying to do. If you really feel like you need to write
some sort of wrapper for this, I'd suggest keeping the case you deal
with down to a simple situation: 1 child object with a OneToOneField
or a ForeignKey to a parent object.

Joseph

--~--~---------~--~----~------------~-------~--~----~
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