In tutorial 6 we learn about static files, and about how to correctly
include them in our polls app. Following along with the tutorial exactly
however leads us to a situation where the static files are not correctly
included in the application and therefore our style.css does not get
imported to our application.
The issue lies in tutorial 2 - where we first included our polls app in
settings.py via INSTALLED_APPS:
{{{#!python
INSTALLED_APPS = [
'polls.apps.PollsConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
}}}
Using this method, static files do not get correctly imported to the app
for inclusion in templates/etc
To fix this in the polls application, modifying INSTALLED_APPS as below
produces the expected behavior (static files get included and can be
accessed via templates.
{{{#!python
INSTALLED_APPS = [
'polls',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
}}}
According to apollo13 this seems to be a bug with handling of static files
with app configs.
A quick fix for the tutorials may be changing the include text to just be
"polls" vs "polls.apps.PollsConfig" however this may not be the desired
syntax for app config includes.
--
Ticket URL: <https://code.djangoproject.com/ticket/29034>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* resolution: => worksforme
Comment:
I can't reproduce a problem and if there were a bug, I think we'd have
heard about it before now. You can seek help on
[wiki:TicketClosingReasons/UseSupportChannels our support channels]. If
you provide an upload of your project, someone may be able to debug it and
find where you went wrong.
--
Ticket URL: <https://code.djangoproject.com/ticket/29034#comment:1>