0

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

from notifications import AllNotificationsList

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

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

我的问题是:

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

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

谢谢你。

4

1 回答 1

0

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

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

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

于 2020-06-12T09:11:36.700 回答