Static file not working

I have problem … I have this structure, but static file not works … grrrrr. Whats wrong? In documentation 3.0 is the same …

My app name web.

web

  • migrations
  • static
    • web
      • style.css

{% load static %}
<link rel="stylesheet" href="{% static "web/style.css" %}">

How are your running your application? Are you talking about in debug / testing mode using runserver, or are you talking about in a production mode?

The two answers are different.

In a test/debug mode, there are settings file settings that need to be set -
see the static-files how-to page.

In a production environment, you may want the static files served by your webserver (Nginx / Apache). If your settings are correct, you would use the “collectstatic” management command to copy those files to the directory from which they can be served.

1 Like

Just as an addendum to the excellent answer by Ken: If you don’t want to have to deal with static files configurations in production, take a look at whitenoise.

2 Likes

I use django projects directy in PyCharm … all run on windows 10 in local development …

Can you post the output of the ./manage.py collectstatic command, and full paths and configuration of your production server ?