是不是可以添加一个ManyToManyField的原因? [英] Is a reason I can't add a ManyToManyField?

查看:208
本文介绍了是不是可以添加一个ManyToManyField的原因?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我正在构建一个Django应用程序,
这些是我拥有的几个模型:

  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)

同步模型我' m得到这个错误:

  AttributeError:'ManyToManyField'对象没有属性'_get_m2m_column_name'

是否有原因发生?如何解决这个问题?



帮助将非常感激。






编辑



我正在使用django-evolution http://code.google.com/p/django-evolution/

解决方案

我建议你使用django-extensions,这将给你一个比进化更好的commnad sqldiiff ,因为创建我们建议您运行命令 sqlall yourapp 并直接执行sql代码。创建新的中间表。进化不适合你:(


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/

解决方案

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 :(

这篇关于是不是可以添加一个ManyToManyField的原因?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆