我无法为带有m2m(ManyToManyField)的模型运行服务器。模型字段本身如下所示:
...
class Some(TimeStampedModel):
relate = models.CharField(max_length=10000, blank=False)
related_relate = models.ManyToManyField('self', through='RelatedM2M',
symmetrical=False, related_name=_('related_relate'))
...
然后面对导入错误:
django.core.urlresolvers.NoReverseMatch: Reverse for 'related_phrases' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
我不明白它是怎么工作的。。。从this的帖子中我发现我需要create the reverse relationship manually yourself via the through model
但是这意味着什么?到底发生了什么,它抛出了这个错误,以及如何处理m2m不对称领域的模型是相关的?你知道吗
更新 django.core.urlresolvers文件.NoReverseMatch的名称:
class NoReverseMatch(Exception):
pass
什么??你知道吗
正如Django docs中所写的here,我需要在m2m model中的related\u name属性的末尾添加
+
,并在m2m字段中设置与其名称不同的related\u name。你知道吗相关问题 更多 >
编程相关推荐