Locked lesson.
About this lesson
There are a few ways to style your pages within Django. In this lesson, we'll cover how to use Custom CSS.
Exercise files
Download this lesson’s related exercise files.
Using Custom CSS.docx57.5 KB Using Custom CSS - Solution.docx
57.8 KB
Quick reference
Using Custom CSS
You can use custom CSS in your Django project by adding a static directory to your app and defining it in your settings.py file.
When to use
Use a static directory any time you want to add or use custom CSS in your Django project.
Instructions
In Sublime Text, right click on the resume directory and choose "Add Folder", name it static.
Inside that static directory, create another directory named "resume" (or whatever your app is called).
Inside that resume directory, create a directory called CSS. Inside that directory, add your css file.
In your settings.py file, at the bottom of the file, add this code:
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static'),
]
To use css file, use the load static tag and a static tag:
{% load static %}
{% static 'resume/css/style.css' %}
Hints & tips
- The static directory holds CSS, Javascript, and Images
- Be sure to load static on any webpage you want to use static files
- Use a static tag to specify the static file you wish to use.
Lesson notes are only available for subscribers.