于项目同名目录下settings文件中找到以下代码,并将csrf行注释:
1 MIDDLEWARE = [ 2 ‘django.middleware.security.SecurityMiddleware‘, 3 ‘django.contrib.sessions.middleware.SessionMiddleware‘, 4 ‘django.middleware.common.CommonMiddleware‘, 5 #‘django.middleware.csrf.CsrfViewMiddleware‘, 6 ‘django.contrib.auth.middleware.AuthenticationMiddleware‘, 7 ‘django.contrib.messages.middleware.MessageMiddleware‘, 8 ‘django.middleware.clickjacking.XFrameOptionsMiddleware‘, 9 ]
配置静态文件目录static
于项目同名目录下settings文件末尾追加(注意末尾逗号-,):
STATICFILES_DIRS={ os.path.join(BASE_DIR,‘static‘), }
注册APP
于项目同名目录下settings文件中找到以下代码,并添加APP:
INSTALLED_APPS = [ ‘django.contrib.admin‘, ‘django.contrib.auth‘, ‘django.contrib.contenttypes‘, ‘django.contrib.sessions‘, ‘django.contrib.messages‘, ‘django.contrib.staticfiles‘, ‘app‘, #在此添加app为APP名称 ]
原文地址:https://www.cnblogs.com/bigfei28/p/10293324.html
时间: 2024-09-30 09:28:22