After upgrading from Django 1.9 to 1.10, I've experienced a change in behaviour with a field provided by the django-geolocation package.
This is the change that was made for 1.10 compatibility that broke the behaviour: https://github.com/philippbosch/django-geoposition/commit/689ff1651a858d81b2d82ac02625aae8a125b9c9
Previously, if you initialized a model with a GeopositionField, and then immediately accessed that field, you would get back a Geoposition object. Now you just get back the string value that you provided at initialization.
How do you achieve the same behaviour with Django 1.10? Is there another method like from_db_value that needs to be overridden to call to_python?
After lots of digging it turns out that in
1.8the behaviour of custom fields was changed in such a way thatto_pythonis no longer called on assignment to a field.https://docs.djangoproject.com/en/1.10/releases/1.8/#subfieldbase
Here's a Django ticket with some more discussion on this change: https://code.djangoproject.com/ticket/26807
So in order to retain the old behaviour you need to do something like this:
And then add this to the custom field:
Solution was taken from this pull request: https://github.com/hzdg/django-enumfields/pull/61