Sunday, September 21, 2014

Error dynamically adding a field to a model in Django 1.7

Hi folks

My app django-mptt has a function which dynamically adds a field to a model. A common use-case is hierarchical groups:

from mptt.models import TreeForeignKey, register
from django.contrib.auth.models import Group
TreeForeignKey(Group, blank=True, null=True).contribute_to_class(Group, 'parent')
register(Group)


This works great until Django 1.7. I've recently added 1.7 to the tox config and now I'm getting errors during the migration process:

django.db.utils.OperationalError: no such column: auth_group.parent_id

(full traceback here)

Seems the migration system isn't handling the monkey-patched field properly.

Does anyone know how to avoid this?

Cheers
Craig de Stigter

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5aaf213c-f648-4d3d-818a-c64fe7fedfc1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment