[Django] #29034: App Configs do not correctly handle static files

8 views
Skip to first unread message

Django

unread,
Jan 17, 2018, 6:09:53 PM1/17/18
to django-...@googlegroups.com
#29034: App Configs do not correctly handle static files
-------------------------------------+-------------------------------------
Reporter: nanomebia | Owner: nobody
Type: Bug | Status: new
Component: | Version: 2.0
contrib.staticfiles | Keywords: staticfiles
Severity: Normal | appconfigs
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
When following along with the djagno Polls tutorial I noticed the
following behavior:

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.

Django

unread,
Jan 17, 2018, 10:51:32 PM1/17/18
to django-...@googlegroups.com
#29034: App Configs do not correctly handle static files
-------------------------------------+-------------------------------------
Reporter: nanomebia | Owner: nobody
Type: Bug | Status: closed
Component: contrib.staticfiles | Version: 2.0
Severity: Normal | Resolution:
| worksforme
Keywords: staticfiles | Triage Stage:
appconfigs | Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* 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>

Reply all
Reply to author
Forward
0 new messages