Django:我如何创建没有相关名称的外键?
问题描述:
我遇到了碰撞自动相关名称的问题,并且通常不需要在相关模型上安装外部管理器。Django:我如何创建没有相关名称的外键?
例如,它会如果我能是巨大的:
class ExtraWidgetThingy(models.Model):
product = models.ForeignKey("product.Product")
also_tastes_good_with = models.ForeignKey(
"product.Product", related_name=None)
,而不是related_name='extrawidgetthingys_that_also_tastes_good_with_this'
完美,感谢您对文档的参考。这非常有帮助! – leech 2011-03-18 13:26:14
感谢这个答案 - 任何想法为什么他们选择“+”来表示这个而不是''''或'None'?只是出于好奇! – 2015-07-16 19:16:51
'None'似乎也适用于现在。 – 2015-12-24 07:12:57