Despite numerous attempts, I cannot get my CSS to render properly on any of the HTML pages within a Django project. I've tried various solutions from Stack Overflow, such as adding the following code snippet:
<link rel="stylesheet" href="{% static "styles.css" %}" type="text/css" media="screen" />
, referenced in this thread: Django static files (css) not working. I also experimented with changing it to <link rel="stylesheet" href="{% static 'style.css' %}" />
, based on suggestions in another article: Unable to Apply CSS on my HTML file Django
The current structure of my inbox.html file is as follows:
{% extends "mail/layout.html" %}
{% load static %}
<link rel="stylesheet" href="{% static 'styles.css' %}" />
{% block body %}
<div id="inbox-view">
<h3>Inbox</h3>
<button id="show-email-row" class="btn default"> email row </button>
<button
class="btn default">Default</button>
</div>
{% endblock %}
{% block script %}
<script src="{% static 'mail/inbox.js' %}"></script>
{% endblock %}
Additionally, here is my styles.css file contained within the '''static''' folder:
textarea {
min-height: 400px;
}
.btn {
border: 2px solid black;
background-color: white;
color: black;
padding: 14px 28px;
font-size: 16px;
cursor: pointer;
}
.default {
border-color: #e7e7e7;
color: black;
}
.default:hover {
background: #e7e7e7;
}
The desired outcome is for the button to change color upon hovering and feature a dark background.
Edit
This is what my urls.py looks like:
from django.urls import path
from . import views
urlpatterns = [
path("", views.index, name="index"),
path("login", views.login_view, name="login"),
path("logout", views.logout_view, name="logout"),
path("register", views.register, name="register"),
# API Routes
path("emails", views.compose, name="compose"),
path("emails/<int:email_id>", views.email, name="email"),
path("emails/<str:mailbox>", views.mailbox, name="mailbox"),
]
The aforementioned parent folder's urls.py comprises:
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('mail.urls'))
]
Furthermore, here are the settings derived from setting.py:
"""
Django settings for project3 project.
Generated by 'django-admin startproject' using Django 3.0.2.
... [remaining content remains unchanged]