通过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-hq
和 djangorestframework
包。
$ 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的散列
算法 | 散列摘要 | |
---|---|---|
SHA256 | ddc586e65ee94828b723ddaa27a9c697f3c3d94d730facdb89770ff2634e65a0 |
|
MD5 | b65273f04e9ab1e05e1c1c851cde8e19 |
|
BLAKE2b-256 | 9afa99661bd692c22c4a2eea2479a84960b5847e7abf0630565ee3148892d933 |
关闭
django_notifications_rest-1.0.1-py2.py3-none-any.whl的散列
算法 | 散列摘要 | |
---|---|---|
SHA256 | 4dc0599ba88254e847cfee9e371085a3925ada4e57ea7c3f2e5c103cf451238c |
|
MD5 | 6fe124c02a7d8352f1b4a0d06f70a600 |
|
BLAKE2b-256 | d883d0069f214d0f5a8f38ea3800819c73eb1ecf7388199273f6496a35b19683 |