Ticket #128 (closed defect: fixed)
Support class-level constants
|Reported by:||carl@…||Owned by:||andrew|
I often define class-level constants for things like choices:
class MyModel(models.Model): (STATUS_DRAFT, STATUS_PUBLISHED) = range(2) ... status = models.IntegerField(default=STATUS_DRAFT, choices=...)
This causes breakage every time I freeze models or auto-create (via --model or --auto) any migration involving that field, because STATUS_DRAFT gets thrown blindly into the migration / frozen model as a default value, in a context where it has no definition.
Is there any reasonable solution to this, to prevent having to make irritating manual edits to every single migration? I haven't looked at it in depth; perhaps it's an unavoidable symptom of South's design choice to do things by parsing models.py rather than introspecting model objects.