django loaddata DeserializationError: [u"'127' value must be either None, True or False."]

StackOverflow https://stackoverflow.com/questions/13334849

  •  28-11-2021
  •  | 
  •  

Question

I keep getting the following traceback when trying to load my database. I went on my production server and did a ./manage.py dumpdata appname data.json and then locally tried to run ./manage.py loadata

Problem installing fixture 'donor.json': Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/django/core/management/commands/loaddata.py", line 190, in handle
    for obj in objects:
  File "/Library/Python/2.7/site-packages/django/core/serializers/json.py", line 47, in Deserializer
    raise DeserializationError(e)
DeserializationError: [u"'127' value must be either None, True or False."]

In my models all my boolean fields are NullBooleanField with blank=True,null=True set. I don't see what this is getting upset with. I've never tried this process before. I was just trying to get a copy of prodcution on my local for testing purposes. My database is MySQL btw.

Was it helpful?

Solution

This error means that the Django is trying to import value 127 into a BooleanField and it can't because 127 is not either a boolean or null value.

Are you sure that the models are identical in both production and development? Is it possible that in production, some field in one of your models was an integer, however later in development you changed that to a boolean. If the models are not identical, then you can't just import the fixtures dumped in your production to your development environment. In that case, you will have to do a migration. For Django, South is an excellent tool for doing that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top