🚀 Django Day 19 — Adding Static Files Today I learnt how to add styling to my Django project because the page was looking a bit bland 😅 — and of course, for learning purposes too! In Django, CSS files are called static files because they don’t change — they’re fixed resources like images, stylesheets, or scripts 🧱. So, I created a new folder in my challenges app (talked about in Day 4) and named it “static”. Inside that folder, I added my very first CSS file called “challenges.css” 🎉. To make Django recognize and use the CSS in my templates, I first had to create a space for the CSS block inside my parent template — base.html (from Day 16). I did this using Django’s block and endblock tags like this: {% block css_files %} {% endblock %} This basically reserves a special spot where each page can plug in its own CSS. Then, in my index.html, I linked the stylesheet like this: {% block css_files %} <link rel="stylesheet" href="{% static 'challenges/challenges.css' %}"> {% endblock %} The CSS rule I added in challenges.css was a simple one — it removes the bullet points from the list of months, giving it a neater and more professional look. So, if you compare the video from Day 15, where every month had bullet points • • •, you’ll notice that in today’s video those bullets are completely gone 🪄 — all thanks to the CSS I implemented through Django’s static files system. More to come 💻✨ #Django #Python #WebDevelopment #Frontend #CSS #100DaysOfCode #LearningInPublic #PythonJourney #lexisslearns 🚀

To view or add a comment, sign in

Explore content categories