In Django, getting a "Error: Unable to serialize database" when trying to dump data? In Django, getting a "Error: Unable to serialize database" when trying to dump data? django django

In Django, getting a "Error: Unable to serialize database" when trying to dump data?


Could be something similar to this.

Run it with:

python manage.py dumpdata --indent=2 -v 2 --traceback gigs 

To see the underlying error.


I once ran in a similar problem where the error message was as mesmerizing as yours. The cause was a lack of memory on my server. It seems that generating dumps in json is quite memory expensive. I had only 60meg of memory (at djangohosting.ch) and it was not enough to get a dump for a mysql DB for which the mysql dump was only 1meg.

I was able to find out by watching the python process hit the 60meg limit using the top command in a second command line while running manage.py dumpdata in a first one.

My solution : get the mysql dump and then load it on my desktop pc, before generating the json dump. That said, for backup purposes, the mysql dumps are enough.

The command to get a mysql dump is the following :

mysqldump -p [password] -u [username] [database_name] > [dump_file_name].sql

That said, your problem could be completely different. You should really look at every table that has a foreign key to your Location table, and check if there is no field pointing to a previously deleted location. Unfortunately MySQL is very bad at maintaining Referential integrity, and you cannot count on it.


you can --exclude that particular app which is creating problem , still there will be database tables , it worked for me

python manage.py dumpdata > backedup_data.json --exclude app_name