I've recently started learning Django and I've been having a lot of issues with implementing css into my code. I've found a lot of people with the same issue as me but I am still unable to find an answer.
Currently when I run open the website it give me this https://i.sstatic.net/cL1I3.jpg
And I'm not sure if this is because of the settings, the actual css or something in the html.
My html boilerplate
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>homepage</title>
<link rel="stylesheet" type="test/css" href="{% static'css/home.css' %}"/>
</head>
settings.py
DEBUG = True
STATIC_ROOT = ''
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
ALLOWED_HOSTS = ['127.0.0.1', 'localhost']
STATIC_URL = '/static/'
views.py
from django.contrib import admin
from django.urls import path
from django.conf import settings
from django.conf.urls.static import static
from leatherbiscuit.views import index
urlpatterns = [
path('admin/', admin.site.urls),
path('', index),
]
if settings.DEBUG:
urlpatterns+=static(settings.STATIC_URL,document_root=settings.STATIC_ROOT)
urls.py
from django.shortcuts import render
from django.http import HttpResponse
from django.views.generic import TemplateView
def index(request):
return render(request, 'index.html')
def home_view(request):
return HttpResponse(request, 'index.html')