[u"'' is not a valid JSON string."] Validation error.
timonweb opened this issue · 6 comments
This happened to me at Django 1.5.1 when I upgraded my version of Fandjango. The problem is in models.py, class User:
extra_data = jsonfield.JSONField()
Problem solved by setting
default={} for jsonfield.JSONField() as this:
extra_data = jsonfield.JSONField(default={})
Thanks! If you submit a pull request for this I'll merge it straight away.
Are you sure, this is the main problem? Because django-jsonfield should set {} as a default automatically.
From https://bitbucket.org/schinckel/django-jsonfield/
"If no default is provided, and null=True is not passed in to the field constructor, then a default of {} will be used."
Morpho, you're right. It doesn't solve the problem, re-tested once again. But the source is close. The thing is, when you upgrade to latest fandjango, you run a migration 0010_auto__add_field_user_email__add_field_user_locale__add_field_user_gend.py it adds 'extra_data' field. Despite it has default set to {} it does nothing and creates 'extra_data' column with empty values. This breaks the whole app, the problem is solved by adding '{}' to empty 'extra_data' column values.
I though my fix solves that, but it doesn't since it replicates what jsonfield does by default. Sorry for a confusion, but the bug is still here.
This seems to be a south problem. In https://github.com/jgorset/fandjango/blob/master/fandjango/migrations/0010_auto__add_field_user_email__add_field_user_locale__add_field_user_gend.py#L28 I even set the default, but it does not seem to work, probably we have to set keep_default=True?
+1 for fix it!