Your Ad Here

Friday, January 6, 2012

dumpdata and self referencing foreign keys

I have a model which represents a tree structure using a foreign
key to itself:

class Foo(models.Model):
name = models.CharField(max_length=30)
parent = models.ForeignKey('Foo')

My problem is that "django-admin dumpdata" does not sort the rows
such that it avoids forward references for the foriegn key values,
which is a problem since I'm using MySQL InnoDB tables. I see
that this problem seems to be fixed in the devel tree
(https://code.djangoproject.com/ticket/3615), but I just wanted to
make sure there wasn't something I could easily do in the interim.

Since I know there are no circular references, I can write a
script to postprocess the dumpdata output and reorder to avoid
forward references.

Is there an easier alternative that I've missed?

Thanks!

me

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 comments:

Post a Comment