Is there a reason why I can not add ManyToManyField?

So, I am building a Django application, and these are a few models that 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 synchronizing models, I get 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 greatly appreciated.


EDIT:

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

+2
source share
2 answers

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

sqlall yourapp sql . : (

+3

MagicType ( ) Spell?

magic_types = models.ManyToManyField('MagicType') ( "MagicType" )?

+3

Source: https://habr.com/ru/post/1729324/


All Articles