Django Dumpdata Error Unable To Serialize Database
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss unable to serialize database relation does not exist the workings and policies of this site About Us Learn more
Error Unable To Serialize Database User Matching Query Does Not Exist
about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack commanderror: unable to serialize database: user matching query does not exist. Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up In Django, getting a “Error: Unable to serialize database” when trying to dump data? up vote 10 down vote favorite 1 I'm getting an error when I'm trying to dump data to a JSON fixture in Djanog 1.2.1 on my live server. On the live server it's running MySQL Server version 5.0.77 and I imported a lot of data to my tables using the phpMyAdmin interface. The website works fine and Django admin responds as normal. But when I try and actually dump the data of the application that corresponds to the tables I get this error: $ python manage.py dumpdata --indent=2 gigs > fixtures/gigs_100914.json /usr/local/lib/python2.6/site-packages/MySQLdb/__init__.py:34: DeprecationWarning: the sets module is deprecated from sets import ImmutableSet Error: Unable to serialize database: Location matching query does not exist. My Django model for 'gigs' that I'm trying to dump from looks like this in the models.py file: from datetime import datetime from django.db import models class Location(models.Model): name = models.CharField(max_length=120, blank=True, null=True) class Meta: ordering = ['name'] def __unicode__(self): return "%s (%s)" % (self.name, self.pk) class Venue(models.Model): name = models.CharField(max_length=120, blank=True, null=True) contact = models.CharField(max_length=250, blank=True, null=True) url = models.URLField(max_length=60, verify_exists=False, blank=True, null=True) # because of single thread problems, I left this off (http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.URLField.verify_exists) class Meta: ordering = ['name'] def __unicode__(self): return "%s (%s)" % (self.name, self.pk) class Gig(models.Model): date
Error: Unable to serialize database: User matching query does not exist. I knew this might not work out since I was dealing with a legacy database, but the resolution is quite simple. First I had to http://stackoverflow.com/questions/3708119/in-django-getting-a-error-unable-to-serialize-database-when-trying-to-dump-d narrow it down to which app was causing this. Naturally I assumed it was one of the two apps I had, either common or restaurant. So I ran: ./manage.py dumpdata common and ./manage.py dumpdata restaurant. http://davedash.com/2009/09/13/resolving-django-dumpdata-errors/ The latter had no problem whatsoever. This made sense, since my common application was the only one that made any reference to a User. By looking in my models.py for that application, I narrowed it down to my Profile object. Sure enough, commenting it out meant I could get my data. It ended up being a foreign key mismatch between the profile and user tables. Since this is legacy data, this mismatch made sense. A simple SELECT id,userid FROM profile WHERE userid NOT IN (SELECT id FROM auth_user) gave me a list of bad profiles. Removing them allowed me to create my Django fixtures.
van GoogleInloggenVerborgen veldenZoeken naar groepen of berichten
table which is the mapping for amany-to-many field.The table is called Part and it has a ManytoManyField calledcategory_id.When I run python manage.py dumpdata store.part_category_id >file.jsonI get the error Error: Unable to serialize database: Category matchingquery does not exist.I have validated that all values in the table are valid.The table is defined as follows --> id: integer PRIMARY KEYunipart_id: integer category_id: integerAlso, when I run dumpdata on the table (python manage.py dumpdatastore.part > file.json), the data is dumped without an error messagebut the category_id field is consistently empty in the output.Any thoughts on what I'm doing wrong?Thanks,Natasha--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. reply Tweet Search Discussions Search All Groups django-users 4 responses Oldest Nested Bill Freeman I think that you have to dumdata one or both of the models at the ends of the many to many, and the join table will come along for free. On Tue, Jul 3, 2012 at 3:21 PM, [email protected] wrote: -- 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 Bill Freeman at Jul 3, 2012 at 9:55 pm ⇧ I think that you have to dumdata one or both of the models at the endsof the many to many,and the join table will come along for free.On Tue, Jul 3, 2012 at 3:21 PM, natasha.baker@utoronto.cawrote:Hi All,I'm trying to dump the contents of a table which is the mapping for amany-to-many field.The table is called Part and it has a ManytoManyField calledcategory_id.When I run python manage.py dumpdata store.part_category_id >file.jsonI get the error Error: Unable to serialize database: Category matchingquery does not exist.I have validated that all values in the table are valid.The table is defined as follows --> id: integer PRIMARY KEYunipart_id: integer category_id: integerAlso, when I run dumpdata on the table (python manage.py dumpdatastore.part > file.json), the data is dumped without an error messagebut the category_id field is consistently empty in the output.Any thoughts on what I'm doing wrong?Thanks,Natasha--