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

2010-06-29 Thread Daniel Roseman
On Jun 28, 5:47 pm, thusjanthan  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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



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

2010-06-29 Thread derek
On Jun 28, 6:47 pm, thusjanthan  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.

Sounds a lot like "tagging".  Have a look at this:
http://showmedo.com/videotutorials/video?name=1100020=110

Even if its not exactly what you want, it may give you some ideas...

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Creating and binding more than one model to a from

2010-06-28 Thread thusjanthan
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 received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.