Fix serializing JSONField for migration files.

Review Request #7686 — Created Oct. 9, 2015 and submitted — Latest diff uploaded

Information

Djblets
release-0.9.x

Reviewers

JSONField wasn't migration-friendly, as a default value of anything but
a string would attempt to get fed into the database backend, breaking it
when applying migrations. Fixing that manually would then result in
Django thinking the value has changed again, prompting new migrations.

We now have a custom deconstruct() method, which serializes the field
for migrations. We simply encode the default value to a string, much
like how it'd be stored in the database, so that the migration files
will have safe and comparable values.

Successfully generated migration files that had serialized values. I also
attempted to generate new ones after using the hand-fixed migration files,
and saw that Django no longer thought it needed to generate new migration
files.

    Loading...