Thanks, that didn't show up in my search, but it's exactly the same
traceback.

The ticket description seems to indicate the bug only applies to
testing situations, but clearly it occurs in the default ModelForm
(and thereby in the admin) any time a foreign key is set to
null=False, blank=True.  Leaving a field blank and filling it in in
the model's save() method seems to be a pretty common case, and I
would think should be allowed without creating a custom ModelForm.

Should this be listed somewhere as a backwards-incompatible change,
since it worked in 1.0?



On Jun 24, 6:22 pm, Karen Tracey <kmtra...@gmail.com> wrote:
> On Thu, Jun 24, 2010 at 5:40 PM, ringemup <ringe...@gmail.com> wrote:
> > Upgrading from Django 1.0 to 1.2, I'm suddenly getting errors when
> > creating objects in the admin form a class that essentially looks like
> > this:
>
> > class MyObject(models.Model):
> >  name = models.CharField(max_length=50)
> >  other_thing = models.ForeignKey(MyOtherModel, null=False,
> > blank=True)
>
> >  def save(self, *args, **kwargs):
> >    logging.debug('saving here')
> >    if not self.other_thing:
> >      other_thing = MyOtherModel()
> >      other_thing.save()
> >      self.other_thing = other_thing
> >   super(MyObject, self).save(*args, **kwargs)
>
> > Creating a MyObject in the admin and leaving the other_thing field
> > blank results in the following error:
>
> > Cannot assign None: "MyObject.other_thing" does not allow null values.
>
> There is a ticket open on this:http://code.djangoproject.com/ticket/13776
>
> Karen
> --http://tracey.org/kmt/

-- 
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