Just a guess, but do you want multiple form classes for saving a main
object and its related objects ? in that case, may be you are looking
for inline formsets
[https://docs.djangoproject.com/en/dev/topics/forms/modelforms/#using-an-inline-formset-in-a-view]

Also, I have written a small jquery plugin
[https://github.com/kodeplay/augForm] for handling the adding/removing
of forms in a formset on the client side. It includes a django formset
helper which achieves this by manipulating the management form
associated with the formset using javascript.  Might be of your help..

Regards,
Vineet

On Tue, Mar 13, 2012 at 11:36 AM, Amit Sethi <amit.pureene...@gmail.com> wrote:
> Hi all , I have a certain problem with django forms that seems to me
> should definitely have a solution already written.
>
> I have a couple of different forms that are submitted in the same view
> something like  ...( Sorry just using pseudo code for now )..
>
>
>    class Form1():
>        #different attributes
>
>    Class Form2()
>        #different attributes
>
>
>
>
> `<html>`
>
>    <form >
>
>     {{ 1-instance-Form1 }}
>
>      {{ 2-instance-Form1 }}
>
>    {{ 1-instance-Form2 }}
>    {{ 2-instance-Form2 }}
>
>    </form>
>
> `</html>`
>
> Apart from that I want to give the user the ability to add a form
> instance of one of the form classes available through jquery so the
> form might become
> `<html>`
>
>    <form >
>
>
>         {{ 1-instance-Form1 }}
>
>          {{ 2-instance-Form1 }}
>
>        {{ 1-instance-Form2 }}
>        {{ 2-instance-Form2 }}
>        {{ 3-instance-Form2 }}
>
>    </form>
>
> `</html>`
>
> Now while looking for a solution to handle such a problem I came
> accross the concept of django formset which as the documentation
> describes is a collection of instances of the same Form class. However
> as I can see formsets can have the ability to handle heterogenous
> forms as well:
>
> With some definitions changed
>
>
>    class BaseHeterogenousFormSet(StrAndUnicode):
>
>        def append(form):
>        #add one more form to the formset
>
>        def is_valid():
>        #run is_valid for each of the forms in the formset
>
>        def clean():
>            #run the clean for each of the forms ...
>
>
>
> Is there something wrong with the way i am thinking about this problem
> ??   Is this a proper way a handle the problem that I am describing
>
> --
> A-M-I-T S|S
> _______________________________________________
> BangPypers mailing list
> BangPypers@python.org
> http://mail.python.org/mailman/listinfo/bangpypers



-- 
Vineet Naik
_______________________________________________
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailman/listinfo/bangpypers

Reply via email to