#CSS Issue

21 messages · Page 1 of 1 (latest)

wary pendant
#

Hello! Im new using DjAngo, I want to know how can I create CSS Files and use them in my html files.
I watched videos and the documentation but im very confused, if someone can help me, it would be good

sick flicker
#

That's not unusual. Please try explaining what is confusing. Someone may be able to help then

wary pendant
#

I want to use CSS to make my html looks good, but I have a problem syncing it

#

I dont know how to the href work with this framework, I checked the documentation

#

It tolds me something about static files, but I cant understand them

#
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/5.0/howto/static-files/

STATIC_URL = 'static/'```
#

I tried doing that, creating a static folder and adding to it ''index.css'' for my index.html file

#

Tried to sync it in my html href static/index.css but didnt work

sick flicker
wary pendant
#

CSS Issue

sick flicker
#

If you're still confused, show your template code.

wary pendant
#
{% load static %}

<!DOCTYPE html>
<html lang="es">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Minimalista y Moderno</title>
    <link rel="stylesheet" href="{% static 'css/base.css' %}">
</head>
<body>
    <header>
        <h1>Minimalista y Moderno</h1>
    </header>
    <main>
        <section>
            <h2>¡Bienvenido!</h2>
            <p>Este es un diseño minimalista y moderno.</p>
        </section>
    </main>
    <footer>
        <p>&copy; 2024 Minimalista y Moderno</p>
    </footer>
</body>
</html>
#

This is my Html

sick flicker
#

How does django know to look in that directory?

wary pendant
#

Also in my settings.py, there is a STATIC_URL = 'static/'

sick flicker
#

From the article I shared,

STATICFILES_DIRS tells Django where to look for static files in a Django project, such as a top-level static folder

wary pendant
#

So, how can I make it work?