I am trying to add a custom field to a Django project that uses South . Because of this, I am trying (for the first time) to write introspection rules for the South . I find my case to be the simplest as I am simply extending CharField. In particular:
class ColorField(models.CharField): def __init__(self, *args, **kwargs): kwargs['max_length'] = 10 super(ColorField, self).__init__(*args, **kwargs) def formfield(self, **kwargs): kwargs['widget'] = ColorPickerWidget return super(ColorField, self).formfield(**kwargs)
This is from a Django fragment called the jQuery color picker model field for those interested.
Since I am not adding any new attributes, I believe that I need to add these lines of code:
from south.modelsinspector import add_introspection_rules add_introspection_rules([], ["^myproject\.myapp\.models\.ColorField"])
This is probably obvious, but where should they go? Also, I suppose that is all I have to do right?
I looked at a few of the questions posted here, but most of them relate to much more complex introspections.
Per http://south.readthedocs.org/en/latest/customfields.html#where-to-put-the-code , I tried puttin code at the top of my models.py file, where a custom field is defined. But that did not work.
source share