跳转到主要内容

通过API Rest公开的django通知包

项目描述

django-notifications-rest 文档

django-notifications-rest 提供了 django-notifications-hq 的 rest 端点。

需求

  • Python 3.8 - 3.11
  • Django 4.2 - 5.0
  • django-notifications-hq 最新版本
  • djangorestframework 最新版本

安装

使用 pip 安装。您需要手动安装所需的 django-notifications-hqdjangorestframework 包。

$ pip install django-notifications-rest

或从源代码获取

$ git clone https://github.com/yhdelgado/django-notifications-rest.git
$ cd django-notifications-rest
$ python setup.py sdist
$ pip install dist/django-notifications-rest*

要将Django Notifications Rest添加到您的项目中,请将应用notifications_rest添加到您的INSTALLED_APPS和urlconf中。

应用应该放在所有将要生成通知的应用之后,例如django.contrib.auth

INSTALLED_APPS = (
    'django.contrib.auth',
    'rest_framework',
    'notifications'.
    ...
    'notifications_rest',
    ...
)

将通知URL添加到您的urlconf中:

urlpatterns = [
    ...
    url('^notifications/', include('notifications_rest.urls')),
    ...
]

如果已安装的django版本≥3.1,则:

from django.urls import path, include
urlpatterns = [
    ...
    path('^notifications/', include('notifications_rest.urls')),
    ...
]

要运行模式迁移,请执行python manage.py migrate


其他选项

还有一个/add/ API端点用于添加新通知。这样的端点可能被视为安全风险,因为任何用户都可以添加任何通知。因此,必须通过设置NOTIFICATIONS_API_ALLOW_ADD=True手动启用。

项目详情


下载文件

下载适合您平台的应用程序。如果您不确定选择哪个,请了解有关安装包的更多信息。

源分发

django_notifications_rest-1.0.1.tar.gz (7.1 kB 查看散列)

上传时间

构建分发

django_notifications_rest-1.0.1-py2.py3-none-any.whl (8.7 kB 查看散列)

上传时间 Python 2 Python 3

支持者:

AWSAWS云计算和安全赞助商DatadogDatadog监控FastlyFastlyCDNGoogleGoogle下载分析MicrosoftMicrosoftPSF赞助商PingdomPingdom监控SentrySentry错误日志StatusPageStatusPage状态页面