static file serve nothing is load in deployment

25 views
Skip to first unread message

luca72.b...@gmail.com

unread,
Jun 15, 2022, 6:08:01 AM6/15/22
to Django users
Hello i have this configuration in settings.py

STATIC_URL = '/static_files/'
STATIC_ROOT =  'D:/prova_nuovo_sito/static_files'

INSTALLED_APPS = [
    'polls.apps.PollsConfig',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]

The folder where I store the file is  'D:/prova_nuovo_sito/static_files'
in this folder I have a subfolder polls with all the needed file

The template I write as follow:
{% load static %}
    <link rel="stylesheet" href="{% static "polls/style.css" %}" media="screen">

What is wrong
Thanks

Antonis Christofides

unread,
Jun 15, 2022, 6:45:54 AM6/15/22
to django...@googlegroups.com

Is this in production? Are you using apache or something? if yes, please take a look at https://djangodeployment.readthedocs.io/en/latest/_images/how-static-files-work-apache.png. Otherwise, please explain in more detail what your deployment environment looks like.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8398ea8b-63da-40c1-90e6-fedd08594085n%40googlegroups.com.

luca72.b...@gmail.com

unread,
Jun 15, 2022, 6:54:09 AM6/15/22
to Django users
no i'm not in production
i'm running with runserver 

Ryan Nowakowski

unread,
Jun 15, 2022, 8:24:34 AM6/15/22
to django...@googlegroups.com
I would check a couple of things:

1. You need to have DEBUG set to True in your settings.py[a]
2. Make sure D:/prova_nuovo_sito/static_files/polls/style.css exists

[a] https://docs.djangoproject.com/en/4.0/howto/static-files/#configuring-static-files

Antonis Christofides

unread,
Jun 15, 2022, 9:50:30 AM6/15/22
to django...@googlegroups.com

If you are running the server with "manage.py runserver", STATIC_ROOT is irrelevant. You should put the "polls" directory in "polls/static", i.e. e.g. "polls/static/polls/style.css"; this is relative to the folder where "manage.py" is.

Reply all
Reply to author
Forward
0 new messages