Wednesday, 4 May 2016

Tips for django settings.py



Make a like this function for locate the directories in your django project settings  insted of calling "os.path.abspath(os.path.join(os.path.dirname ()" every where ( like : static,templates,media )

Help tips

add below function in your settings.py

import os

def root(x):
    return os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..',x))

then you can call it like this

TEMPLATE_DIRS = (

    root('templates')
)

No comments:

Post a Comment