Ever since PR #5567 [1] (which is great, yay CSP) I've been concerned about
the impact it will invariably have on admin themes going forward. By
removing any inline JS, the various admin JS functionality is now
initialized in the JS files where it is much harder to extend or change for
an admin theme. None of the niceties of template blocks and extending
templates exist with the JS files, the only way to extend those would be to
duplicate the entire file, which is a non-starter from a maintenance
perspective. This cuts off the nice options added to these JS files since
themes can no longer effect these options.

Possible ways to resolve this include:
  * Move all JS initialization code to a single file which can be
overridden by an admin theme (still requires duplicating all of the
initialization code)
  * Add an optional attribute to the relevant HTML which prevents the
initialization code from running, allowing themes to manually run
initialization code with custom options

I'm a fan of the second option because it allows the most flexibility. An
admin theme can use custom options without duplicating much code, and a
custom TabularInline subclass can be created and use a custom template and
JS to provide custom options specific to that inline class.

I've added a patch [2] which adds this functionality to the two admin
jQuery plugins which are most likely to be initialized with alternate
options: actions.js and inlines.js. For the former the attribute goes on
the div.actions and for the latter it goes on the
div.js-inline-admin-formset. I used the attribute
'data-disable-document-ready', but the name could just as easily be
'data-disable-auto-initialize' or something shorter if there's distaste for
the long names.

Thoughts? I'd like to restore this ability to easily provide different
options to these admin jQuery plugins before 1.10 is finalized as it will
be harder to put the cat back in the bag if it ships without the ability.

- David

[1] https://github.com/django/django/pull/5567
[2] http://pastebin.com/wcCk8T3n

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAEXbqgwUdzG_WuTC-2h7cCuGReFY-j3GsQN%2B-RxuKBZ_pTWLWQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to