Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
These two tiny changes have saved me from a world of pain and misery. I actually cried because of the problems that this pull request addresses.
The changes do two things:
PlaceholderAdmin(ModelAdmin).Media
Summary: stop importing
jquery.js.min
inPlaceholderAdmin(ModelAdmin).Media
.Django's own
ModelAdmin
already calls in jQuery; so we shouldn't try to import the same thing. (I say 'try' because actually we don't even do that correctly - see the second paragraph at #1584.)Importing
jquery.js.min
breaks attempts to make one's ownadmin/base_site.html
provide a newer jQuery where it's needed.cms/templates/admin/cms/page/plugin_change_form.html
Summary: create a
{% block jquery %}
around<script type="text/javascript" src="{% admin_static_url %}js/jquery.min.js"></script>
incms/templates/admin/cms/page/plugin_change_form.html
.A similar issue. The
plugin_change_form.html
extendsadmin/base_site.html
, and loads jQuery. Now suppose your plugin needs a newer jQuery - there is no way to make that work without removing the jQuery here.By putting it in a
{% block jquery %}
, it's now possible for your plugin's form to point at a template that extendsplugin_change_form.html
and overrides that block with the jQuery you want. Or, if your ownadmin/base_site.html
already imports the jQuery you need, a simple{% block jquery %}{% endblock %}
will prevent the undesired one from being loaded.Breaks no tests, though I'm not sure how to test for this exactly. Works in practice as described above, on both a
PlaceholderAdmin
-based admin, and on a plugin.Saved me from tears.