all django

This commit is contained in:
caoqianming 2020-09-25 10:37:06 +08:00
parent 6d7f38ee11
commit d219c41bd9
2 changed files with 13 additions and 9 deletions

View File

@ -62,7 +62,7 @@ ROOT_URLCONF = 'server.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'DIRS': ['dist'],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
@ -124,6 +124,7 @@ CORS_ORIGIN_ALLOW_ALL = True
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATICFILES_DIRS =[os.path.join(BASE_DIR, 'dist/static')]
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

View File

@ -23,19 +23,22 @@ from rest_framework_simplejwt.views import (TokenObtainPairView,
TokenRefreshView)
from apps.system.views import FileViewSet, LogoutView, Login2View
from django.views.generic.base import TemplateView
router = routers.DefaultRouter()
router.register('file', FileViewSet, basename="file")
urlpatterns = [
path('', TemplateView.as_view(template_name="index.html")),
path('admin/', admin.site.urls),
path('token/', TokenObtainPairView.as_view(), name='token_obtain_pair'),
path('token2/', Login2View.as_view(), name='token_obtain_2'),
path('token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
path('token/black/', LogoutView.as_view(), name='token_black'),
path('system/', include('apps.system.urls')),
path('ability/', include('apps.ability.urls')),
path('docs/', include_docs_urls(title="接口文档",
path('api/token/', TokenObtainPairView.as_view(), name='token_obtain_pair'),
path('api/token2/', Login2View.as_view(), name='token_obtain_2'),
path('api/token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
path('api/token/black/', LogoutView.as_view(), name='token_black'),
path('api/system/', include('apps.system.urls')),
path('api/ability/', include('apps.ability.urls')),
path('api/docs/', include_docs_urls(title="接口文档",
authentication_classes=[], permission_classes=[])),
path('', include(router.urls)),
path('api/', include(router.urls)),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)