about
参考:https://blog.csdn.net/qq_42851418/article/details/108961527
install
pip install django-notifications-hq
# 我使用的时候,版本是1.7.0
pip install django-notifications-hq==1.7.0
使用
1. 项目settins.py配置
python
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'api.apps.ApiConfig',
'notifications', # 配置站内消息,要添加这个app
]
2. 在项目总路由中配置
python
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
# 配置下面这个路由
path('notifications/', include('notifications.urls', namespace='notifications'))
]
3. 执行数据库迁移
bash
python manage.py makemigrations
python manage.py migrate
不报错就OK了。