On Apr 4, 11:56 am, Robert <rob...@iteria.no> wrote:
> I wonder whether you have to save a record to the database BEFORE you
> can update a ManyToMany field?
>
> I came across a post by Karen Tracey that seems to suggest this.
>
> The problem is that I am unable to do so because the ManyToManyField
> in my model has no default value and this triggers an error when I try
> to save without adding a value to it. And when I try to add a value
> django says that the "instance needs a primary key value before a many-
> to-many relationship can be used." Thus, it's kind of a trap, isn't
> it?
>
> I am working on an app with similar models to the document "Making
> queries" athttp://docs.djangoproject.com/en/1.0/topics/db/queries
>
> only that I change the authors-field with a users field pointing to
> the auth.model User.
>
> class Entry(models.Model):
>     [..]
>     users = models.ManyToManyField(User)

No, there isn't usually a trap here. What error do you get when you
try to save without defining a ManyToMany?
--
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.

Reply via email to