我的django模型有问题。在
这是我的模型:
class Item(MPTTModel):
__metaclass__ = TransMeta
name = models.CharField(max_length=250, verbose_name=u'Menu name', blank=True)
parent = TreeForeignKey('self', null=True, blank=True, related_name='children')
class Meta:
translate = ('name',)
class MPTTMeta:
order_insertion_by = ['name',]
我试图在一个模型中合作两件事:TransMeta和MPTTModel。当我试图运行它时,我得到一个错误:
TypeError: Error when calling the metaclass bases metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases
我在google中找到了一个类似的解决方案:http://code.activestate.com/recipes/204197-solving-the-metaclass-conflict/并将我的代码改成这样:
^{pr2}$其中classmaker是这个代码http://code.activestate.com/recipes/204197-solving-the-metaclass-conflict/#block-0。但是翻译不起作用。当我试图得到一个型号.名称我收到一个错误:
FieldDoesNotExist at /admin/menu/item/add/
Item has no field named 'name'
目前没有回答
相关问题 更多 >
编程相关推荐