标签:contex ace dex missing got operator djang port options
settings.py
#设置文件上传路径,图片上传、文件上传都会存放在此目录里
MEDIA_URL = ‘/media/‘
MEDIA_ROOT = os.path.join(BASE_DIR, ‘media‘)
#PEP8:missing whitespace around operator os前后有空格都不行
TEMPLATES = [
{
‘BACKEND‘: ‘django.template.backends.django.DjangoTemplates‘,
‘DIRS‘: [os.path.join(BASE_DIR, ‘templates‘)]
,
‘APP_DIRS‘: True,
‘OPTIONS‘: {
‘context_processors‘: [
‘django.template.context_processors.debug‘,
‘django.template.context_processors.request‘,
‘django.contrib.auth.context_processors.auth‘,
‘django.contrib.messages.context_processors.messages‘,
‘django.template.context_processors.media‘,
],
},
},
]
urls.py
from django.contrib import admin
from django.urls import path,include,re_path
from django.views.static import serve
from django.conf.urls.static import static
from myblog import settings
from blog import views
urlpatterns = [
path(‘admin/‘, admin.site.urls),#管理后台
path(‘‘, views.index, name=‘index‘),#网站首页
path(‘list-<int:lid>.html‘, views.list, name=‘list‘),#列表页
path(‘show-<int:sid>.html‘, views.show, name=‘show‘),#内容页
path(‘tag/<tag>‘, views.tag, name=‘tags‘),#标签列表页
path(‘s/‘, views.search, name=‘search‘),#搜索列表页
path(‘about/‘, views.about, name=‘about‘),#联系我们单页
path(‘ueditor/‘, include(‘DjangoUeditor.urls‘)),
re_path(‘^media/(?P<path>.*)$‘, serve, {‘document_root‘: settings.MEDIA_ROOT}),
]
标签:contex ace dex missing got operator djang port options
原文地址:https://www.cnblogs.com/master-road/p/10355915.html