How to add css, js or other local files in Django project ?


First of All put these lines into file:

os.path.join(BASE_DIR, ‘latest/static/’)
STATIC_ROOT = os.path.join(BASE_DIR, ‘static’)
STATIC_URL = ‘/static/’

then write:

python collectstatic 

it will bring all of your css and js files into your project root directory.

And Then open up your any template file and go to the <html> element, then write this line of code below <html> tag:

{% load staticfiles %}

Now you can access any local static file using this code:

{% static ‘admin/css/base.css’ %}


<link rel=”stylesheet” type=”text/css” href=”{% static ‘admin/css/base.css’ %}”>


  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.