Django Class Based FormView and multiple forms

1,586 views
Skip to first unread message

Michel Thadeu Sabchuk

unread,
Jun 8, 2011, 10:33:31 AM6/8/11
to Django users
Hi guys,

Is there a general guideline to work with class based generic views
and multiple forms? I already use FormView but it seems focused on a
single form.

Suppose a user profile registration: with function based views, I use
two forms, one for the user account and other for the profile.

I can start directly on the TemplateView or I can fill the FormView
with 2 forms (with some customization) but, before it, I want to know
if anyone didn't find a better way to do it ;)

Some recommendation?

Best regards.

--
Michel Sabchuk
Curitiba - Brasil
http://turbosys.com.br/

Russell Keith-Magee

unread,
Jun 16, 2011, 10:02:43 AM6/16/11
to django...@googlegroups.com
On Wed, Jun 8, 2011 at 10:33 PM, Michel Thadeu Sabchuk
<mich...@gmail.com> wrote:
> Hi guys,
>
> Is there a general guideline to work with class based generic views
> and multiple forms? I already use FormView but it seems focused on a
> single form.
>
> Suppose a user profile registration: with function based views, I use
> two forms, one for the user account and other for the profile.
>
> I can start directly on the TemplateView or I can fill the FormView
> with 2 forms (with some customization) but, before it, I want to know
> if anyone didn't find a better way to do it ;)
>
> Some recommendation?

This is a known limitation of FormView, inherited from it's heritage
in the function-based generic views. There is an open ticket [1] that
aims to address some of these limitations; more broadly, this is an
area where I think there is lots of room for improvement now that we
have a class-based foundation to work with.

[1] https://code.djangoproject.com/ticket/16256

Yours,
Russ Magee %-)

Michel Thadeu Sabchuk

unread,
Jun 16, 2011, 10:43:13 AM6/16/11
to Django users
Hi Russ,

> ... this is an
> area where I think there is lots of room for improvement now that we
> have a class-based foundation to work with.

Thanks for your reply!

I started my own "multiple forms view":

https://gist.github.com/1029336

I see the ticket's approach is much more complete, I will see how I
can help.

Best regards!

--
Michel Sabchuk
Brasil

Iván Raskovsky

unread,
Jun 16, 2011, 7:05:13 PM6/16/11
to django...@googlegroups.com
On Thu, Jun 16, 2011 at 11:43 AM, Michel Thadeu Sabchuk
<mich...@gmail.com> wrote:
> Hi Russ,
>
>> ... this is an
>> area where I think there is lots of room for improvement now that we
>> have a class-based foundation to work with.
>
> Thanks for your reply!
>
> I started my own "multiple forms view":
>
> https://gist.github.com/1029336
>
> I see the ticket's approach is much more complete, I will see how I
> can help.

Hi Michel this looks great!

Would you like to merge it with my work[0']? Maybe attach a pull request?

We should agree on naming conventions for the methods, and maybe have
the same hooks. You can look at my work in the patch of #16256 or
here[1].

Why are you using a dict instead of a list?

Oh, we should also add some tests for this new view.

Regards,
Iván

[0] https://github.com/rasca/django/tree/ticket16256-more-class-based-views
[1] https://github.com/rasca/django/blob/ticket16256-more-class-based-views/django/views/generic/edit/formset.py

Reply all
Reply to author
Forward
0 new messages