Serving static file with django

I am new to Django and am trying to learn how to serve static files in local deployment. I have read this and many other possible related problems from stackoverflow but i cant seem to be able to find solve my problem.

This is my settings , I cant figure out what is the reason Django isnt serving my static files

STATIC_URL = '/html/'

In my templates I refer to them as

<link rel="stylesheet" href="css/style.css" type="text/css" media="all" />

The structure of my html file which is located at C:/Users/RayLim/Desktop/project/home/username/djcode/mysite/mysite/templates


This is the server response

"GET /home/css/images/big1.jpg HTTP 1.1" 404 3782


First, static files and templates are usually in separate directories but I don't think there would be any problem (that I'm aware of...)

Next, you want to make sure that you use a template tag to represent the static file location instead of using css/.. which expects there to be a css directory relative to whatever url you are currently viewing.

There are a couple template tags you can use, I use {{ STATIC_URL }}

So replace

<link rel="stylesheet" href="css/style.css" type="text/css" media="all" />


<link rel="stylesheet" href="{{ STATIC_URL }}css/style.css" type="text/css" media="all" />

And you should be all set...

You should avoid hard linking to your static directories. It can cause confusion and potential problems as your project gets bigger

Please refer to this, it has everything you need.

Django staticfiles app help

Need Your Help

VB.NET Match string between parentheses (brackets)

regex match brackets parentheses

Looking for a pattern for matching text between brackets.

Use Server-sent events from two scripts

javascript php server-sent-events

I am using SSE for my real time application. I have sort of two types of notifications I need to check on database, one type is whenever the is an update, then sent to browser(it can take 1 hour, 2...