Opened 3 years ago

Closed 3 years ago

#19065 closed Cleanup/optimization (needsinfo)

The FilteredManyToMany widget needs javascript in 'stacked.html' and 'tabular.html' when using inline content

Reported by: replytosander@… Owned by: nobody
Component: contrib.admin Version: 1.4
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I'm developing a custom sortable manytomany widget which allows the user to order the items in the widget.

You can find it here:

When using inline models the widget needs the javascript in stacked.html and/or tabular.html. It initializes a new instance when adding an inline item.

To keep the sortedm2m library as pluggable as possible I would like to know how I can provide this javascript in the library. This way a developer doesn't need to override the admin templates.

This doesn't seem possible at the moment. Maybe there should be a way to provide document ready javascript in the scope of the widget.

Any ideas on this?

Change History (2)

comment:1 Changed 3 years ago by anonymous

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Code used in overridden stacked.html template:

var updateOrderedSelectFilter = function() {
            // If any SelectFilter widgets are a part of the new form,
            // instantiate a new SelectFilter instance for it.
            if (typeof OrderdSelectFilter != "undefined"){
                $(".selectfilter").each(function(index, value){
                    var namearr ='-');
                    OrderdSelectFilter.init(, namearr[namearr.length-1], false, "{% admin_media_prefix %}");
                $(".selectfilterstacked").each(function(index, value){
                    var namearr ='-');
                    OrderdSelectFilter.init(, namearr[namearr.length-1], true, "{% admin_media_prefix %}");

comment:2 Changed 3 years ago by aaugustin

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

This is a feature request, and it isn't very precise. In such cases, it's best to write to the django-developers mailing list, and open a ticket once a concrete action plan has been determined.

Overriding admin templates is the canonical way to inject additional features in the admin pages. Your library can ship templates replacing the admin's built-in templates; they will be used if you app comes before django.contrib.admin in INSTALLED_APPS.

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