Code

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#14693 closed (fixed)

staticfiles app doesn't work with form media framework and 3rd party asset managers

Reported by: jezdez Owned by: nobody
Component: Contrib apps Version: 1.3-alpha
Severity: Keywords:
Cc: oleg.lomaka@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

As discussed with Russell and Carl on IRC (after quite some feedback on the mailing list), the current proposal to fix this is:

  • Introduce new core settings: STATIC_URL, STATIC_ROOT (which refer to non-user files, canonical setting for root of all static content)
  • form media and admin are modified to use this instead (starting to deprecate ADMIN_MEDIA_PREFIX?)
  • staticfiles app uses it too, as a replacement for its current STATICFILES_URL, STATICFILES_ROOT (this is actually compaptible with the original 3rd party staticfiles app)
  • for existing projects we keep defaulting form media to MEDIA_URL and have checks ready for the migrated projects
  • new projects automatically enable staticfiles app and aren't problematic

Attachments (4)

14693.1.diff (36.1 KB) - added by jezdez 3 years ago.
Initial patch
14693.2.diff (49.1 KB) - added by jezdez 3 years ago.
Moved context processors and template tags to core since those settings are core settings.
14693.2.2.diff (49.2 KB) - added by jezdez 3 years ago.
Moved context processors and template tags to core since those settings are core settings.
14693.3.diff (83.1 KB) - added by jezdez 3 years ago.
Final patch

Download all attachments as: .zip

Change History (8)

Changed 3 years ago by jezdez

Initial patch

comment:1 Changed 3 years ago by carljm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

Patch looks good. A couple notes:

  1. It looks like the get_staticfiles_prefix tag was removed completely (which is fine with me, tbh), but the docs reference a "get_static_prefix" tag, which I don't see.
  1. If STATIC_* are core settings now, should the static context processor move to core rather than staticfiles? I think it should.

comment:2 Changed 3 years ago by alek

  • Cc oleg.lomaka@… added

Changed 3 years ago by jezdez

Moved context processors and template tags to core since those settings are core settings.

Changed 3 years ago by jezdez

Moved context processors and template tags to core since those settings are core settings.

Changed 3 years ago by jezdez

Final patch

comment:3 Changed 3 years ago by jezdez

  • Resolution set to fixed
  • Status changed from new to closed

(In [14592]) Fixed #14693, #14709 -- Backwards incompatible change to rectify the confusion around the STATICFILES_URL and STATICFILES_ROOT settings.

  • Two new global settings that will be used by -- but are not limited to -- the staticfiles app: STATIC_ROOT and STATIC_URL.
  • Moving the 'django.contrib.staticfiles.templatetags.staticfiles' template tag to the core ('django.templatetags.static') and renaming it to 'get_static_prefix'.
  • Moving the context processor 'django.contrib.staticfiles.context_processors.staticfiles' to the core ('django.core.context_processors.static') and renaming it to 'static'.
  • Paths in media definitions will use STATIC_URL as the prefix if the value is not None, and falls back to the previously used MEDIA_URL.

Thanks again to the community for constructive criticism and Carl and Russ for sanity-inducing discussions on IRC.

comment:4 Changed 3 years ago by jacob

  • milestone 1.3 deleted

Milestone 1.3 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.