Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix Django South issue with regards to localflavor in Django 1.5?

I'm starting a new project and I'm using Django 1.5. I found out that the localflavor stuff has been removed from Django 1.5 and is now a separate installable package. So I installed it. In my models.py I'm importing the U.S. localflavors to get my states:

from django_localflavor_us.models import USStateField

In my model, I have this field:

state = USStateField(default='VA')

When I attempt to run a migration with South, I get the following message now:

! Cannot freeze field 'playerstats.location.state' ! (this field has class django_localflavor_us.models.USStateField)

! South cannot introspect some fields; this is probably because they are custom ! fields. If they worked in 0.6 or below, this is because we have removed the ! models parser (it often broke things). ! To fix this, read http://south.aeracode.org/wiki/MyFieldsDontWork

I read through the wiki article, but I find it very verbose and complex. My USStateField isn't considered a custom field now in 1.5 is it? Has anyone else run into this issue in 1.5? And how did you resolve it?

like image 241
user338413 Avatar asked Mar 11 '13 13:03

user338413


3 Answers

As of django-localflavor version 1.0, simply adding "localflavor" to your INSTALLED_APPS is all you need to get South to properly pick it up. https://django-localflavor.readthedocs.org/en/latest/?highlight=south#installation

like image 142
Aaron Avatar answered Nov 07 '22 17:11

Aaron


Have you tried adding the introspection rule?

add_introspection_rules([], ["^django_localflavor_us\.models\.USStateField"])
like image 23
Hedde van der Heide Avatar answered Nov 07 '22 17:11

Hedde van der Heide


I had to tweak Hedde van der Heide's solution to get mine to work. It looks like this:

add_introspection_rules([], ["^localflavor\.us\.models\.USStateField"])

like image 2
Stephen Avatar answered Nov 07 '22 18:11

Stephen