body {
font-family: Arial, sans-serif;
}
h1 {
color: #007bff;
}
p {
margin-bottom: 20px;
}
.highlight {
background-color: #f4f4f4;
padding: 10px;
border-left: 3px solid #007bff;
margin-bottom: 20px;
}
Welcome to Django Course Episode 4
In this episode, we will learn how to add static files such as CSS and images to our Django project.
Adding CSS
Cascading Style Sheets (CSS) allows us to style our web pages and make them visually appealing. In Django, we can add CSS files to our project by creating a ‘static’ directory within our app and placing the CSS file inside it. We then link the CSS file in our HTML templates using the <link>
tag.
Adding Images
Images are an important part of web development, and in Django, we can add images to our project by placing them in the ‘static’ directory as well. We can then use the <img>
tag in our HTML templates to display the images on our web pages.
Episode 4 Tasks
For this episode, your tasks are:
- Create a ‘static’ directory within your app
- Add a CSS file and an image to the ‘static’ directory
- Link the CSS file in your HTML templates using the
<link>
tag - Display the image on your web page using the
<img>
tag
Tip: Remember to run the collectstatic
command to collect all static files into the ‘static’ directory of the main project.
Once you have completed these tasks, you will have a better understanding of how to add static files such as CSS and images to your Django project.
Stay tuned for the next episode, where we will learn more about Django’s powerful features!
great
Smart bro👍👍👍👍👍🙏🙏🙏🙏🙏