The problem was that syncdb does not "alter table" - it apparently
just creates. Thus even though the app now treated these relations as
optional, the database did not.

Thanks!

On Feb 13, 10:44 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Wed, 2008-02-13 at 19:34 -0800, SeanFromIT wrote:
> > I have a class with ManyToManyFields that are 'optional' relations. If
> > I set the ManyToManyField to null=True and blank=True, the admin
> > interface treats it as optional, but when I hit Save I get the error:
>
> > OperationalError at /admin/app/report/add/
> > (1048, "Column 'addedBy_id' cannot be null")
>
> I suspect this isn't the error you think it is. Firstly,
> ManyToManyFields are pretty much implicitly null=True always. This is
> because you have to save an object before you can add things to its
> many-to-many fields.
>
> Secondly, if model XYZ has a ManyToManyField, there's no column in the
> database table for XYZ corresponding to that field. Instead, there's the
> intermediate table. So that column error can't be coming from a column
> in the table for XYZ.
>
> Could you post the smallest failing example possible to show what's
> going on here. The only way I can imagine getting that error is if it's
> caused by the intermediate table (linking your model to the other
> model). That would mean the admin interface was lettting you add
> something that wasn't already saved, which would elicit complaints frmo
> everybody using ManyToManyFields in the admin interface. The two columns
> in the intermediate table are named after the models they link, so is
> one of you models called "addedBy"? If not, you're debugging the wrong
> problem.
>
> So, recheck what's going on here. Maybe everything you say is accurate,
> but I'm a little suspicious. If it is correct, shrink your example to
> the smallest possible failing example and then record every step you do
> (maybe even take a screenshot or two to show the situation right before
> you press "save"). On the information you've provided so far, it's a
> little hard to work out what might be going on.
>
> Regards,
> Malcolm
>
>
>
> > So, what's the proper way to make the m2m relation optional?
>
> --
> I don't have a solution, but I admire your 
> problem.http://www.pointy-stick.com/blog/
--~--~---------~--~----~------------~-------~--~----~
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