Skip to content
Advertisement

Implementing CSS in Django

I’m trying to implement a simple CSS file to my python web app. When I try loding the app, I get a error message in the command prompt that says:

JavaScript

And of course no CSS is implemented to the HTML page. The structure of my Project is:

JavaScript

In my settings.py, I got:

JavaScript

And in the html I got the link tag inside the head like:

JavaScript

How do I correctly implement the CSS in my web app? Do I’ve to add something to the url.py? Or is it in the settings.py using the STATIC_ROOT or STATICFILES_DIRS?

I’m using Django 1.9.

My urls.py file contains the following code:

JavaScript

This is the urls.py inside the MyApp folder.

I have an extra urls.py file inside a MyTeachingApp folder that contains:

JavaScript

I tried adding the static statement to this urls.py file and still didn’t work.

Advertisement

Answer

You need to add your app to INSTALLED_APPS tuple. Also, add the urlpatterns for serving static files with your local development server, like mastazi said:

JavaScript

Your app is named MyTeachingApp so it seems; your INSTALLED APPS configuration should look like:

JavaScript
Advertisement