As a note... I've worked around this for the time being by setting
cascade on delete explicitly in db.  That said, I'd still like to know
if this is a bug or if I'm doing something wrong with my models.
Jon.

On Oct 9, 11:28 am, Jon Loyens <[EMAIL PROTECTED]> wrote:
> See the following set of models:
>
> class Mom(models.Model):
>     name = models.CharField(max_length=80)
>
>     def __unicode__(self):
>         return self.name
>
> class Dad(models.Model):
>     name = models.CharField(max_length=80)
>
>     def __unicode__(self):
>         return self.name
>
> class Child(models.Model):
>     name = models.CharField(blank=True, max_length=100)
>     mom = models.ForeignKey(Mom)
>     dad = models.ForeignKey(Dad, null=True, blank=True)
>
>     def __unicode__(self):
>         return self.name
>
> In admin if you create a Child with a Mom and a Dad, and then attempt
> to delete the Mom, it works as expected (prompt to make sure you're
> okay deleting the children, click okay, Mom and Child objects are
> deleted).  However, if you attempt to delete the, Dad, you'll get a
> prompt asking if it's okay to delete the Child but upon clicking Okay,
> you get an integrity error.
>
> I'm using MySQL and innoDB.  Here's a link to the traceback:
>
> http://dpaste.com/83431/
>
> Is this a bug I'm seeing or am I missing something in either my models
> or configuration?  Or do I not understand how ForeignKeys where
> null=True are supposed to work?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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