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 trialJuan Perez
Courses Plus Student 8,944 PointsWhy is my CSS not being applied?
Hi, Im following the django tutorial on my computer and for some reason the stuling is not being applied from the static folder. What might be the problem?
Directory Structure.
├── courses
│ ├── __init__.py
│ ├── __init__.pyc
│ ├── __pycache__
│ │ ├── __init__.cpython-35.pyc
│ │ ├── admin.cpython-35.pyc
│ │ ├── models.cpython-35.pyc
│ │ ├── urls.cpython-35.pyc
│ │ └── views.cpython-35.pyc
│ ├── admin.py
│ ├── admin.pyc
│ ├── apps.py
│ ├── migrations
│ │ ├── 0001_initial.py
│ │ ├── __init__.py
│ │ ├── __init__.pyc
│ │ └── __pycache__
│ │ ├── 0001_initial.cpython-35.pyc
│ │ └── __init__.cpython-35.pyc
│ ├── models.py
│ ├── models.pyc
│ ├── templates
│ │ └── courses
│ │ └── course_list.html
│ ├── tests.py
│ ├── urls.py
│ └── views.py
├── db.sqlite3
├── learning_site
│ ├── __init__.py
│ ├── __init__.pyc
│ ├── __pycache__
│ │ ├── __init__.cpython-35.pyc
│ │ ├── settings.cpython-35.pyc
│ │ ├── urls.cpython-35.pyc
│ │ ├── views.cpython-35.pyc
│ │ └── wsgi.cpython-35.pyc
│ ├── settings.py
│ ├── settings.pyc
│ ├── urls.py
│ ├── urls.pyc
│ ├── views.py
│ ├── views.pyc
│ ├── wsgi.py
│ └── wsgi.pyc
├── manage.py
├── static
│ └── css
│ └── layout.css
└── templates
├── home.html
└── layout.html
layout.html
{% load static from staticfiles %}
<!DOCTYPE html>
<html>
<head>
<title>{% block title %}{% endblock title %}</title>
<link rel="stylesheet" type="text/css" href="{% static 'css/layout.css' %}">
</head>
<body>
<div class="site-container">
{% block content %}
{% endblock content %}
</div><!-- End div site-container -->
</body>
</html>
This is what is on my settings.py about static files
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'assets'),
)
2 Answers
Kenneth Love
Treehouse Guest TeacherYour STATICFILES_DIRS
adds an "assets"
directory but your directory is named static
.
Juan Perez
Courses Plus Student 8,944 PointsKenneth Love Any suggestion?