【问题标题】:How To Tell Django Ive Overridden A Third Party App如何告诉 Django 我已经覆盖了第三方应用程序
【发布时间】:2020-10-01 00:14:09
【问题描述】:

我想为Django-Notifications 视图添加功能。我想最好的方法是重写类,添加我的自定义逻辑,然后将类传递给 super:

from notifications import AllNotificationsList

class CustomAllNotificationsList(AllNotificationsList):
    def get_queryset(self):
        # my custom logic
        return super(CustomAllNotificationsList, self).get_queryset(self)

我知道 this 覆盖 Django Admin 的指南,但我找不到如何为其他第三方包执行此操作。

我的问题是:

  1. 我不知道把这个被覆盖的类放在哪里(在我的项目树中)。

  2. 我不知道如何告诉 Django 它已被覆盖(settings.py?)。

谢谢。

【问题讨论】:

    标签: django django-apps django-notification django-packages


    【解决方案1】:

    这就是我最终这样做的方式:

    https://medium.com/@RStein/extending-third-party-django-app-without-touching-its-code-d35fb136c08f

    这有点hacky,但它是我能找到的最好的。

    【讨论】:

      猜你喜欢
      • 2020-05-29
      • 1970-01-01
      • 1970-01-01
      • 2018-05-22
      • 2014-03-07
      • 2016-08-20
      • 1970-01-01
      • 2021-02-06
      • 2021-02-14
      相关资源
      最近更新 更多