wiki:MyFieldsDontWork

Version 2 (modified by andrew, 4 years ago) (diff)

--

My fields don't work!

You've likely arrived at this page because South has told you it can't understand how to freeze one or more of your fields.

The problem

South needs to be able to call the constructor of a field to be able to re-make it; thus, when a field is "frozen", it's stored as a full path to the class along with the arguments to its constructor.

For core Django fields and popular Django apps, South knows how to convert the state of a class into its constructor, but for other apps, and your own fields, you must tell it how to get this information.

How did it work before?

In previous versions of South, if introspection failed, we opened up models.py and used the Python parser module to try and get the definition out manually. This worked in a surprisingly large amount of cases, but when it broke, it broke spectacularly.

Since we prefer explicit failure modes to a module which could introduce subtle bugs you may not notice until months down the line, the parser module was removed in South 0.7, and the only option now is to explicitly tell South how to freeze your fields.

How do I fix it?

You must write either some introspection rules for your fields or, if they're very peculiar, give them a south_field_triple method.

Having to write all these definitions is annoying!

I know, and it was a hard choice to remove the automatic parser, but it's gone. You only have to write the introspection rules once for each field, and if it's a mainstream Django app, the rules can either be bundled with the app or submitted to South (we're maintaining a group of introspection rules in the introspection_rules/ folder in the codebase).