Hi,

I get OperationalError: (1364, "Field, 'user_id' doesn't have a
default value")

As I understand, the many-to-many relationship shall be taken care of
by a join table.No such table shows up when I run mysql show tables;.
I have of course run a syncdb command. All other tables are present.

Thanks DR

Robert

On 4 apr, 14:10, Daniel Roseman <[email protected]> wrote:
> On Apr 4, 11:56 am, Robert <[email protected]> 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.– Skjul sitert tekst –
>
> – Vis sitert tekst –

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

Reply via email to