I have had a similar problem (prolly still do).
I actually used code like this
ResultForm = forms.form_for_model(Result)
result_forms = []
for i in range(num_forms):
form = ResultForm(prefix=str(i))
result_forms.append(form)
which will convert names of each form's widget like this;
name='student1' => name='1-student1', etc...
then, when i get the request.POST, i just collect all the
post-data to
list of dictionaries and
use bind to forms.
on second thoughts, i think maybe i should have only one
form to
contain multiple forms
and handle all this transparently in the form.
take a look at
http://eggdrop.ch/blog/2007/02/15/django-dynamicforms/
though he uses javascript to generate the forms client-side,
should
give some ideas.
haven't gone through it myself (maybe that's why i have not
done mine
yet )
pls let me know how it goes
happy holidays!!!
On Dec 23, 7:34 pm, Chaves <desdecha... gmail.com> wrote:
> Dear Sirs:
>
> I have this model
>
> class Student(models.Model):
> name = models.CharField(max_length=50)
>
> class StudentGroup(models.Model):
> name = models.CharField(max_length=20)
> student = models.ForeignKey(Student)
>
> class Subjects(models.Model):
> name = models.TextField()
> studentgroup= models.ForeignKey(StudentGroup)
>
> class ExamScore(models.Model):
> name = models.CharField(max_length=20)
> examdate = models.DateField()
> student = models.ForeignKey(Student)
> subject = models.ForeignKey(Subject)
> score = models.CharField(max_length=5)
>
> Im looking for a way to generate this form:
> ---------------------------------------------------
> Exam:__________ (input text)
> Date:_____________(input text)
> Subject:_________ (select)
>
> Student nš 1:________(input text)
> Student nš 2:________(input text)
> Student nš 3:________(input text)
> Student nš 4:________(input text)
> Student nš 5:________(input text)
> Student nš 6:________(input text)
>
> Save
>
>
-------------------------------------------------------
>
> i know a way to do that in the classical process: send
to the template two
> lists:
>
(subjectList=Subject.object.filter(studentgroup="groupA
")); and
> (studentList=
> StudentGroup.objects.filter(name="groupA")).
The form in rendered in the
> template.
>
> My main propose is to do that using newforms. Anybody
can help?
>
> Thanks a lot and Happy Christmas.
> --
> View this message in context:http://www.nabble.com/newforms-and-many-
objects-instances-tp14479408p...
> Sent from the django-users mailing list archive at
Nabble.com.
--~--~---------~--~----~------------~-------~--~----~
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-unsubscribe googlegroups.com
For more options, visit this group at htt
p://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---
|