Photologue 的 Photo.get_previous_by_date_add() 方法在哪里定义?
Photologue 模型 Photo
的定义不包含方法 get_previous_by_date_added
及其父模型 ImageModel
。 ImageModel
继承自 django models.Model
基类,该基类也没有此方法。
但是在 Photo
模型中可以使用此方法:
class Photo:
...
def get_previous_in_gallery(self, gallery):
try:
return self.get_previous_by_date_added(galleries__exact=gallery,
is_public=True)
except Photo.DoesNotExist:
return None
...
它的定义在哪里? (链接到 Photologue models.py )
Definition of Photologue model Photo
doesn't contain method get_previous_by_date_added
, as well as its parent model ImageModel
. ImageModel
inherits from django models.Model
base class which hasn't this method too.
But there is usage of this method in Photo
model:
class Photo:
...
def get_previous_in_gallery(self, gallery):
try:
return self.get_previous_by_date_added(galleries__exact=gallery,
is_public=True)
except Photo.DoesNotExist:
return None
...
Where its definition lives? (link to Photologue models.py)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它是由
DateField
的contribute_to_class
方法添加的,如 模型实例参考 - 另请参阅django.db.models.fields。 __init__
。许多 Django 的模型属性是由元类或外部类添加的,因此直接查看 models.Model 源并不总是有帮助。
It's added by the
contribute_to_class
method ofDateField
, as documented in the model instance reference - see also the code ofdjango.db.models.fields.__init__
.A lot of Django's model attributes are added by metaclasses or by external classes, so it doesn't always help to look directly at the models.Model source.