Tuesday, June 29, 2010

Re: Creating and binding more than one model to a from

On Jun 28, 5:47 pm, thusjanthan <thusjant...@gmail.com> wrote:
> Hi,
>
> I have a Topic class I would like to create a form based on. BUT, I
> want many of these objects so Topics. How do I obtain such a feature.
>
> Suppose my form object is as follows:
>
> class TopicForms(ModelForm):
>     class meta:
>         model = Topic
>         fields = ('topic_id','topic')
>
> I want to display more than one of the topics that is associated to a
> particular object. Suppose its a topic about obama and there are 10
> topics. I want to display all 10 of these. and If they make a change
> to one of them I would like to save that change on submission. I would
> also like to provide additional blank topic fields for end users to
> enter new topics about obama. Any help would be appreciated. I am a
> little confused on the forms area of django.
>
> Nathan.

You need formsets. A general introduction is here:
http://docs.djangoproject.com/en/1.2/topics/forms/formsets/
and a guide to building formsets based on models is here:
http://docs.djangoproject.com/en/1.2/topics/forms/modelforms/#id1
--
DR.

--
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 http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment