【发布时间】:2010-01-27 07:56:11
【问题描述】:
我正在创建这个:
# models.py
class Item(models.Model):
sku = models.CharField(max_length=20)
class Attribute(models.Model):
item = models.ForeignKey(Item, related_name='items')
这会导致 Python 中的命名冲突吗?喜欢:
# views.py
some_object.items.create(sku='123abc')
# Is there a place / way that this could cause errors, like:
# AttributeError: Bound method 'items' has no attribute "create"
# Since items() on a dict-like object could be a method to return a list,
# and Django could add support for .items() on a queryset right?
如果这是一个坏主意,我可以更改名称。
【问题讨论】:
标签: python django naming-conventions naming