0

So I have the file main.html which is being returned unstyled even though I have style.css in /polls/static/polls/style.css

Here is main.html (cut down for simplicity)

{% load static %}<!DOCTYPE html>
<html>
  <head>
    <link rel="stylesheet" href="{% static 'polls/style.css' %}">
  </head>

my settings.py has this for the static URL:

STATIC_URL = '/static/'

Yet it still returns it unstyled while the console gets returned 404 1671:

"GET /polls/static/polls/style.css HTTP/1.1" 404 1671

Here is my directory: Directory

The fix is probably easy I'm just a newbie at Django

Thanks

2
  • Hi, interesting, perhaps check in developer tools if the css link is getting loaded? Commented Sep 30, 2020 at 22:57
  • I mean its obviously not getting loaded if I'm getting a 404 but the error I get is "GET /static/polls/style.css HTTP/1.1" 404 1671 So the path is correct but its not loading it Commented Sep 30, 2020 at 23:39

1 Answer 1

2

You should add STATICFILES_DIRS to your settings file. Like this:

STATICFILES_DIRS = [os.path.join(BASE_DIR, 'polls/static')]
Sign up to request clarification or add additional context in comments.

1 Comment

This didn't change anything do i have to modify this somehow? I edited settings.py to be: STATIC_URL = '/static/' STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')] But still same error

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.