Friday, April 30, 2010

Django ManyToMany error: "Cannot resolve keyword XXX into a field"

1 comment:

  1. Thank you so much!! I've just been battling a similar error. It turned out that a piece of code I've written long ago also fsck'ed up the load order of model classes.

    My error was that I in the ForeignKey field of one model referenced another model as a default value:

    class Model1(models.Model):
    x = ForeignKey(Model2, default=Model3.objects.get(...))

    class Model4(models.Model):
    x = ManyToManyField(...)

    I should have told myself way back then that setting a static default value as a model instance is a terrible idea.

    ReplyDelete