#22939 closed Bug (fixed)
admin_static templatetag is not using the staticfiles' storage
Reported by: | generalov | Owned by: | Aymeric Augustin |
---|---|---|---|
Component: | Core (Other) | Version: | 1.7-rc-1 |
Severity: | Release blocker | Keywords: | admin_static admin app-loading |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I set STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.CachedStaticFilesStorage'
but I noted what admin pages still contains not hashed urls for static.
It's looks like the static
templatetag from django/contrib/admin/templatetags/admin_static.py is not uses the staticfiles' storage. It seems there is a bug in the implementation.
The condition if apps.is_installed('django.contrib.staticfiles'):
at https://github.com/django/django/blob/master/django/contrib/admin/templatetags/admin_static.py#L6
is always False and staticfiles
backend is nether used.
The implementation of is_installed
method https://github.com/django/django/blob/master/django/apps/registry.py#L205
looks up the application in the self.app_configs. This array is populated consecutively by self.populate method from settings.INSTALLED_APPS.
The default [INSTALLED_APPS](https://github.com/django/django/blob/master/django/conf/project_template/project_name/settings.py#L32) is:
INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', )
The 'django.contrib.auth' is stays before 'django.contrib.staticfiles'. Therefore when, config for 'django.contrib.auth' is populated, then django.contrib.staticfiles
is not configured yet and it is absend in the self.app_configs. Therefore apps.is_installed('django.contrib.staticfiles') returns False.
The current solution is put django.config.staticfiles before django.confib.auth in the INSTALLED_APPS. But it seems the bug in the logic of method Apps.is_installed
because it checks not for application is installed but for application is configured.
Change History (5)
comment:1 by , 10 years ago
Component: | Uncategorized → Core (Other) |
---|---|
Keywords: | app-loading added |
Owner: | changed from | to
Severity: | Normal → Release blocker |
Status: | new → assigned |
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → Bug |
comment:4 by , 10 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
There's no difference between "installing" and "configuring" an app.
Until you've processed all entries in
INSTALLED_APPS
, you haven't resolved allAppConfig.name
values so you don't know which apps are installed.I think we need to reintroduce a flag to tell whether the first phase of the app registry population process is complete and have
is_installed
raise an error if that flag isn't set.In addition, we need to defer the check in
admin_static.py
or at least make sure it doesn't get imported too early.