Lesson 4: Adding Static Files, CSS, and Images in the Django Course

Posted by

Django Course Episode 4 (Add Static files | CSS | Images)

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:

  1. Create a ‘static’ directory within your app
  2. Add a CSS file and an image to the ‘static’ directory
  3. Link the CSS file in your HTML templates using the <link> tag
  4. 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!

0 0 votes
Article Rating
2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
@onguyenvan2196
6 months ago

great

@shashiprakash-a2539
6 months ago

Smart bro👍👍👍👍👍🙏🙏🙏🙏🙏