Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Django Basics Django Templates Static Assets

Sahar Nasiri
Sahar Nasiri
7,454 Points

The css is not applying!

I am using Pychram, and I did add the assets folder. Yet, I do not have anything applied to my home page. I even add color: green to my .site-container, and nothing applied! Here is my code:

{% load static from staticfiles %}
<!DOCTYPE html>
<html lang="en">
        <meta charset="UTF-8">
        <title>{% block title %}{% endblock %}</title>
        <link rel="stylesheet" href="{% static 'css/layout.css' %}">
        <div class="site-container">
            {% block content %}{% endblock %}

3 Answers

Nikki Wong
Nikki Wong
9,066 Points


I had the same problem! but if you add 'learning_site' in before assets, it works!!

STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'learning_site', 'assets'), )

Emanuel Vasconcelos
Emanuel Vasconcelos
4,248 Points

The css may already be working only that you cannot see it. Make sure that you're not looking at your page in a really small window with a small or reduced width. Otherwise, you won't be able to see the padding of the container.

Pachal Debbarma
Pachal Debbarma
Courses Plus Student 3,597 Points

Hi! Sahar, I have the same problem the css does not load even after I have written the whole identical code as the instructor.But this issue does solve.