|
Django 1.6 after settings.py file no TEMPLATE_DIRS template directory and STATICFILES_DIRS static access directory, you need to manually add, recently encountered this problem, the solutions to talk about
1. Environment
System: Ubuntu
django release: Django-1.8.4.tar.gz
2.settings.py Profile Description
An increase of about content
import os
BASE_DIR = os.path.dirname (os.path.dirname (os.path.abspath (__ file__)))
base_dir is engineering project directory, the project directory is the application of an app directory, os.path.dirname (__ file __): directory settings.py file.
3. Indicate TEMPLATE_DIRS path, locate the following code, marked red part is added TEMPLATE directory, defaults to an empty list.
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
# 'BACKEND': '/ root / day10 / s4web / templates',
'DIRS': [. Os.path.join (BASE_DIR, 'templates') replace ( '\\', '/'),],
'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',
],
},
},
]
In fact, behind the replace ( '\\', '/') can not add, the phrase used in the windows in the '\' into '/'.
4.STATICFILES_DIRS configuration is relatively simple, at the end of settings.py add the following code on
STATICFILES_DIRS = (os.path.join (BASE_DIR, 'static'),)
5. Configure complete. |
|
|
|