Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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">
    <head>
        <meta charset="UTF-8">
        <title>{% block title %}{% endblock %}</title>
        <link rel="stylesheet" href="{% static 'css/layout.css' %}">
    </head>
    <body>
        <div class="site-container">
            {% block content %}{% endblock %}
        </div>
    </body>
</html>

3 Answers

Nikki Wong
Nikki Wong
9,066 Points

Hey!

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
PLUS
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.