[Python] I can't load my CSS login page in Django admin

Discussão em 'Python' iniciado por Stack, Novembro 21, 2025.

  1. Stack

    Stack Membro Participativo

    I have a Django project that I deployed without really adding any styling for 2 reasons:


    1. I didn't know any front-end back then.


    2. I wanted to do it for the sake of doing it.

    Now, I have written HTML and CSS for the login page. The first place I want to apply it is the admin page, but this is what I see (as shown in the picture I shared). I can't find the problem in my project.

    I also uploaded the project to GitHub here: https://github.com/manirng/sukablyat-django


    Please ignore the name; I never thought it would go online.
    ​

    @import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;1,300&display=swap');

    *{
    margin: 0px;
    padding: 0px;
    font-family: 'Poppins',sans-serif;
    }

    #bg-video{
    width: 100%;
    height: 100vh;
    position: absolute;
    object-fit: cover;
    }
    section{
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    width: 100%;
    background-position: center;
    background-size: cover;
    }
    .box{
    position: relative;
    width: 400px;
    height: 450px;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px solid white;
    border-radius: 20px;
    }
    h2{
    font-size: 2em;
    color: white;
    text-align: center;
    }
    .input-field{
    position: relative;
    margin: 20px 0;
    width: 310px;
    border-bottom: 2px solid white;
    }
    .input-field label{
    position: absolute;
    top: 50%;
    left: 5px;
    transform: translate(-50);
    color: white;
    font-size: 1em;
    pointer-events: none;
    transition: .5s;
    }
    input:focus ~label,
    input:valid ~label{
    top: -5px;
    }
    .input-field input{
    width: 100%;
    height: 50px;
    background: transparent;
    border: none;
    outline: none;
    font-size: 1em;
    padding: 0 35px 0 5px;
    color: white ;
    }

    .input-field ion-icon{
    position: absolute;
    right: 8px;
    color: black;
    font-size: 1.2em;
    top: 20px;
    }
    .forget{
    margin: 15px 0 15px;
    font-size: small;
    color: white;
    display: flex;
    justify-content: center;
    }
    .forget label input{
    margin-right: 3px;
    }

    .forget label a{
    color: white;
    text-decoration: none;
    }
    .forget label a:hover{
    text-decoration: underline;
    color: blue;
    }
    button{
    height: 40px;
    width: 100%;
    border-radius: 40px;
    background: white;
    border: none;
    outline: none;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    }

    button:hover{
    box-shadow: 1px 5px 7px 1px purple;
    }
    .register{
    font-size: .9em;
    color: white;
    text-align: center;
    margin: 25px 0 10px;
    }
    .register p a{
    text-decoration: none;
    color: white;
    }
    .register p a:hover{
    text-decoration: underline;
    }


    And here is my HTML for reference:

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Login | Page</title>
    {% load static %}
    <link rel="stylesheet" href="{% static 'css/login.css' %}">
    </head>
    <body>
    <section>
    <!-- Update video path to use static files -->
    <video src="{% static 'videos/background.mp4' %}" loop muted autoplay id="bg-video" type="video/mp4"></video>
    <div class="box">
    <div class="form-value">
    <form method="POST">
    {% csrf_token %}

    <!-- Display error messages -->
    {% if messages %}
    <div class="messages">
    {% for message in messages %}
    <div class="alert alert-{{ message.tags }}">
    {{ message }}
    </div>
    {% endfor %}
    </div>
    {% endif %}

    <h2>Login</h2>
    <div class="input-field">
    <ion-icon name="mail-outline"></ion-icon>
    <!-- Change to username and add name attribute -->
    <input type="text" name="username" required>
    <label for="">Username</label>
    </div>
    <div class="input-field">
    <ion-icon name="lock-closed-outline"></ion-icon>
    <!-- Add name attribute -->
    <input type="password" name="password" required>
    <label for="">Password</label>
    </div>
    <div class="forget">
    <label for=""><input type="checkbox">Remember me <a href="#">Can't login?</a></label>
    </div>
    <button type="submit">Login</button>
    <div class="register">
    <p>Don't have an account? <a href="#">Register</a></p>
    </div>
    </form>
    </div>
    </div>
    </section>

    <script type="module" src="https://unpkg.com/ionicons@7.1.0/dist/ionicons/ionicons.esm.js"></script>
    <script nomodule src="https://unpkg.com/ionicons@7.1.0/dist/ionicons/ionicons.js"></script>
    </body>
    </html>


    i think my repo works(it should be on staticfiles,css,login.css and on login.html in the movies templates) now and these are the web page errors:
    Refused to apply style from '<URL>' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

    theme.js:1 Failed to load resource: the server responded with a status of 404 ()

    login/?next=/admin/:1 Refused to execute script from 'https://sukablyat.onrender.com/static/admin/js/theme.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

    nav_sidebar.js:1 Failed to load resource: the server responded with a status of 404 ()

    login/?next=/admin/:1 Refused to execute script from 'https://sukablyat.onrender.com/static/admin/js/nav_sidebar.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

    i've checked online and most people were saying the css root is wrong but im pretty sure it isnt

    root is:

    staticfiles/admin:
    css:
    login.css



    the code i have in my login.html is:

    {% load static %}
    <link rel="stylesheet" href="{% static 'css/login.css' %}">

    Continue reading...

Compartilhe esta Página