I am from PHP background and want to give path to
STATICFILES_DIRS
in settings.py and in windows I understand that I will need to give full path like:
D:/path/to/folder/project/static
I want to know that is there a way to give some path like “/static/” or can we give path like dirname(__FILE__) in PHP?
So that my path is not hardcoded. Also why it is physical path as webserver normally don’t follow physical path for loading CSS files as it use http path? So why it is this way(physical path) in django? Can some one please explain.
thanks for everyone’s effort in advance.
In my settings.py files, I always do
Then you can do
The reason that
STATICFILES_DIRSwants a filesystem path is that it needs to know where the files live in the operating system (so things likemanage.py collectstaticare possible). TheSTATIC_URLsetting is for webserver paths, and that’s what it uses to show to the user in the admin or the{% static %}tag or whatever.STATICFILES_DIRSis server-side only and never shows up in any rendered templates or anything.