views:

148

answers:

2

So I'm building a Django application, and these are a few models I have:

class MagicType(models.Model):

     name = models.CharField(max_length=155)
     parent = models.ForeignKey('self', null=True, blank=True)

class Spell(models.Model):

    name = models.CharField(max_length=250, db_index=True)
    magic_words = models.CharField(max_length=250, db_index=True)
    magic_types = models.ManyToManyField(MagicType)

When syncing the models I'm getting this error:

AttributeError: 'ManyToManyField' object has no attribute '_get_m2m_column_name'

Is there a reason this is happening? How can I fix this?

Help would be very much appreciated.


EDIT:

I'm using django-evolution http://code.google.com/p/django-evolution/

+3  A: 

Is MagicType declared in the same models file (and before) Spell?

Does magic_types = models.ManyToManyField('MagicType') work (with 'MagicType' quoted)?

Ben Edwards
no it doesn't. but thanks though!
RadiantHex
+1  A: 

I suggest you use django-extensions , this will give you a commnad sqldiiff that works better than evolution, because there is a problem creating the intermediate table between MagicType and MagicType.

I suggest you run the command sqlall yourapp and execute directly the sql code of the creation of the new intermediate table. Evolution doesn't it for you :(

diegueus9
Thanks I will look into it, I have extensions already installed, but I have never used that feature. Time to try it out!
RadiantHex