运维咖啡吧

享受技术带来的乐趣,体验生活给予的感动

在项目中使用sadmin

1.Add "sadmin" to your INSTALLED_APPS setting like this:

INSTALLED_APPS = [
    ...
    'sadmin.commons',
    'sadmin.accounts',
    'sadmin.project',
]

2.Add custom MIDDLEWARE for operatrion log

MIDDLEWARE = [
    ...
    'sadmin.commons.middleware.log.OperationLogMiddleware',
    'sadmin.commons.middleware.token.AuthTokenMiddleware',
]

3.Add "AUTH_USER_MODEL" to your setting.py

AUTH_USER_MODEL = 'accounts.User'

4.Include the accounts URLconf in your project urls.py like this::

from django.urls import path, include
from django.views.generic.base import TemplateView
from django.contrib.auth.decorators import login_required

urlpatterns = [
    path('', login_required(TemplateView.as_view(template_name='index.html')), name='index-url'),
    path('commons/', include('sadmin.commons.urls')),
    path('accounts/', include('sadmin.accounts.urls')),
    path('project/', include('sadmin.project.urls')),
]

5.Run python manage.py migrate to create the models.

6.Run python manage.py createsuperuser to create superusers