Django Tutorial
About Lesson

In this Django Tutorial we are going to talk about Django Static Files, so when you are developing a website, generally we need to serve additional files such as images, CSS or JavaScript, in django these files are called static files. django provides django.contrib.staticfiles to help you manage them.



When you are configuring static files make sure that you have these requirements.

  • Make sure that django.contrib.staticfiles is included in your INSTALLED_APPS.
  • In your settings file, define STATIC_URL, for example:



OK now create a new directory in your mysite project, or we can say in your project level directory. and also we are adding our style.css in css folder.

Django Tutorial - Django Static Files
Django Tutorial



Basically we want to change our h1 and our p tag color, add this code in your style.css.




Now you need to open your in your django project, and add this code at the bottom.




After that open your base.html and link your css file with your django project like this.




Also you need to load static at the top of your base.html, if you don’t do this you will receive error.




Now run your project this is the result.

Django Tutorial - Django Static Files
Django Tutorial – Django Static Files




So now these are our files for this tutorial.