user7693832
user7693832

Reputation: 6849

Load staticfies do not work in Django

I am new to python Django.

I have a project like this below:

But in my TestModel APP, there is a index.html here:

<!doctype html>
{% load staticfiles %}
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="Keywords" content="" />
    <meta name="description" content="" />
    <!-- <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;" /> -->
    <title>Python探索馆 - Slice</title>
    <!-- Main Theme -->
    <link rel="stylesheet" href="{% static 'css/style.css' %}" />

    <!-- Font -->
    <link rel="stylesheet" href="http://at.alicdn.com/t/font_n5vylbuqe61or.css" />
  </head>
<body>
...

You see I have load the static files.

And in my testdj/ the settings.py, I have set the STATIC_URL:

STATIC_URL = '/static/'

But in the browser, the stylesheet did not load success.

enter image description here


EDIT-1

The css structrue:

enter image description here

Upvotes: 0

Views: 63

Answers (1)

Daniel Roseman
Daniel Roseman

Reputation: 599796

You have put your static files in your template folder. That is not where they go. You need to put them either in your app or in a folder that is referenced by the STATICFILES_DIRS setting.

Upvotes: 3

Related Questions