Photologue 的 Photo.get_previous_by_date_add() 方法在哪里定义?

发布于 2024-11-18 03:01:25 字数 706 浏览 6 评论 0原文

Photologue 模型 Photo 的定义不包含方法 get_previous_by_date_added 及其父模型 ImageModelImageModel 继承自 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

随遇而安 2024-11-25 03:01:25

它是由 DateFieldcontribute_to_class 方法添加的,如 模型实例参考 - 另请参阅 django.db.models.fields。 __init__

许多 Django 的模型属性是由元类或外部类添加的,因此直接查看 models.Model 源并不总是有帮助。

It's added by the contribute_to_class method of DateField, as documented in the model instance reference - see also the code of django.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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文