create relative paths for your django settings
Mar
22
1
0
I wish Django used this by default, but you should be setting up your project using relative paths in your settings. By not hard coding your paths makes your project easier to manage.
Start by setting a variable to use as the base that pulls it's path dynamically through os.path; I use PROJECT PATH.
import os PROJECT_PATH = os.path.realpath(os.path.dirname(__file__))
You can then append to the PROJECT_PATH variable when setting up your other paths that are based on your project's root path.
MEDIA_ROOT = PROJECT_PATH + '/media/' TEMPLATE_DIRS = ( PROJECT_PATH + '/templates/' )