Error adding ManyToManyField to Django

Ok, so I recently posted an error question when adding ManyToManyField

Models below

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)

This is the error I get when migrating with django-evolution :

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

So, is there a way to manually install ManyToManyField without specifying it in two models? let's say with such a model

class SpellToMagicType(models.Model):
     magic_type = models.ForeignKey(MagicType)
     spell = models.ForeignKey(Spell)

but how can I continue to use this in Django ORM ?

Help would be greatly appreciated. Thank!

+3
source share
2 answers

, , ManyToManyField?, , (ORM) , , django-evolution , django-extensions (http://code.google.com/p/django-command-extensions/) sqldiff,

+3

, . , , , Django 1.1 - .

, ?

+1

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


All Articles