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

3

10

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?

Gyrostatic answered 11/3, 2013 at 13:20 Comment(0)
T
8

Have you tried adding the introspection rule?

add_introspection_rules([], ["^django_localflavor_us\.models\.USStateField"])
Tieback answered 11/3, 2013 at 13:24 Comment(0)
N
12

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

Nisse answered 27/12, 2013 at 12:38 Comment(0)
T
8

Have you tried adding the introspection rule?

add_introspection_rules([], ["^django_localflavor_us\.models\.USStateField"])
Tieback answered 11/3, 2013 at 13:24 Comment(0)
S
2

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"])

Salify answered 11/12, 2013 at 22:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.