Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#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


I set STATICFILES_STORAGE = '' 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/ 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
is always False and staticfiles backend is nether used.

The implementation of is_installed method
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]( is:


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 Changed 4 years ago by Aymeric Augustin

Component: UncategorizedCore (Other)
Keywords: app-loading added
Owner: changed from nobody to Aymeric Augustin
Severity: NormalRelease blocker
Status: newassigned
Triage Stage: UnreviewedAccepted
Type: UncategorizedBug

There's no difference between "installing" and "configuring" an app.

Until you've processed all entries in INSTALLED_APPS, you haven't resolved all 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 or at least make sure it doesn't get imported too early.

comment:4 Changed 4 years ago by Aymeric Augustin <aymeric.augustin@…>

Resolution: fixed
Status: assignedclosed

In 22b2fb0ba1d130c0ff0e1658ee9c2224a619a4a7:

Fixed #22939 -- Delayed admin_static backend detection

Thanks generalov for the report.

comment:5 Changed 4 years ago by Aymeric Augustin <aymeric.augustin@…>

In be38c5bcc8b6d641d210cbcf0508605223366778:

[1.7.x] Fixed #22939 -- Delayed admin_static backend detection

Thanks generalov for the report.

Backport of 22b2fb0b from master

Note: See TracTickets for help on using tickets.
Back to Top