Reputation: 135
So I've seen a lot of tutorials here explaining what to do, but no matter what I change the static files won't seem to load. This is what my files are looking like atm
settings.py
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATICFILES_DIRS = [os.path.join(PROJECT_ROOT, "static"),'']
job_app/urls.py
urlpatterns = [
path('', main, name='index'),
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<title>JobPortal - Free Bootstrap 4 Template by Colorlib</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
{% load static %}
<link href="https://fonts.googleapis.com/css?family=Nunito+Sans:200,300,400,600,700,800,900" rel="stylesheet">
<link rel="stylesheet" href="{% static 'css/open-iconic-bootstrap.min.css' %}">
<link rel="stylesheet" href="{% static 'css/animate.css' %}">
<link rel="stylesheet" href="{% static 'css/owl.carousel.min.css' %}">
<link rel="stylesheet" href="{% static 'css/owl.theme.default.min.css' %}">
<link rel="stylesheet" href="{% static 'css/magnific-popup.css' %}">
<link rel="stylesheet" href="{% static 'css/aos.css' %}">
<link rel="stylesheet" href="{% static 'css/ionicons.min.css' %}">
<link rel="stylesheet" href="{% static 'css/bootstrap-datepicker.css' %}">
<link rel="stylesheet" href="{% static 'css/jquery.timepicker.css' %}">
<link rel="stylesheet" href="{% static 'css/flaticon.css' %}">
<link rel="stylesheet" href="{% static 'css/icomoon.css' %}">
<link rel="stylesheet" href="{% static 'css/style.css' %}">
</head>
<body>
jobber/urls.py
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('job_app.urls'))
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
Upvotes: 1
Views: 390
Reputation: 953
Below configs worked for me. Django only needs two things.
Remove static urlpatterns
from urls.py. Only define STATIC_URL
and STATICFILES_DIRS
in settings.py and remove STATIC_ROOT
.
STATIC_URL = '/static/'
STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static'),)
Upvotes: 2