When I try to generate an initial migration for my Django app with:
python manage.py makemigrations myapp
I get a traceback like:
File "/myproject/.env/local/lib/python2.7/site-packages/localflavor/us/models.py", line 21, in deconstruct
name, path, args, kwargs = super(USStateField, self).deconstruct()
File "/myproject/.env/local/lib/python2.7/site-packages/localflavor/us/models.py", line 21, in deconstruct
name, path, args, kwargs = super(USStateField, self).deconstruct()
File "/myproject/.env/local/lib/python2.7/site-packages/localflavor/us/models.py", line 21, in deconstruct
name, path, args, kwargs = super(USStateField, self).deconstruct()
File "/myproject/.env/local/lib/python2.7/site-packages/localflavor/us/models.py", line 21, in deconstruct
name, path, args, kwargs = super(USStateField, self).deconstruct()
RuntimeError: maximum recursion depth exceeded while calling a Python object
The only odd thing I'm doing that's probably the cause is I'm trying to monkeypatch the USStateField from the localflavor package. Specifically, I need to set custom state choices from the field's state list, so I'm doing:
from localflavor.us import models as us_models
_USStateField = us_models.USStateField
class USStateField(_USStateField):
description = _("U.S. state (two uppercase letters)")
def __init__(self, *args, **kwargs):
kwargs['choices'] = MY_STATE_CHOICES
kwargs['max_length'] = 2
super(_USStateField, self).__init__(*args, **kwargs)
us_models.USStateField = USStateField
This worked perfectly in Django 1.7, but now gives me this error in Django 1.10. Is there a better way to do this?