Django 2 Web Development Cookbook
上QQ阅读APP看书,第一时间看更新

How to do it...

Modify your path-related settings accordingly, instead of hardcoding the paths to your local directories, as follows:

# settings.py
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

# ...

TEMPLATES = [{
# ...
DIRS: [
os.path.join(BASE_DIR, 'templates'),
],
# ...
}]


# ...

LOCALE_PATHS = [
os.path.join(BASE_DIR, 'locale'),
]


# ...

MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'site_static'),
]

FILE_UPLOAD_TEMP_DIR = os.path.join(BASE_DIR, 'tmp'