Skip to content

Django How to get the Root Path

Django: How to get the Root Path#

You may need to create or use a file in the root path of your django project. From any file included in your django project you can run:

import os

__name__ is the name of the class, function, method, descriptor or generator

That will give


How to get the Path of the file you are in#

To get the path of the file you are currently in use:

import os