derek-schaefer / django-json-field

Generic JSON model and form fields.
BSD 3-Clause "New" or "Revised" License
122 stars 86 forks source link

Wrong default value for South migration #32

Open fangsterr opened 10 years ago

fangsterr commented 10 years ago

I create a new field on my model as such:

some_json_field = JSONField(default=[], blank=True)

However, when I generate the schemamigration (using python manage.py schemamigration appname --auto) and migrate, the field on existing model instances for the some_json_field are the string "[]" instead of []

derek-schaefer commented 10 years ago

Thanks for reporting this. I'll look into it.

mboersma commented 10 years ago

We've seen a similar problem with a field default of "{}", which is intended to be an empty JSON object but gets encoded as the literal unicode string "{}". I couldn't figure out exactly where this goes wrong, so I applied a band-aid in our product: https://github.com/deis/deis/pull/1616

If anyone knows where this might be happening, I would love to debug it and push a fix back upstream to django-json-field. It's worked great for us other than this.