#26387: Related popup doesn’t open in a changelist when list_editable in
raw_id_fields
---------------------------------+------------------------------------
     Reporter:  BertrandBordage  |                    Owner:  nobody
         Type:  Bug              |                   Status:  new
    Component:  contrib.admin    |                  Version:  1.8
     Severity:  Release blocker  |               Resolution:
     Keywords:                   |             Triage Stage:  Accepted
    Has patch:  0                |      Needs documentation:  0
  Needs tests:  0                |  Patch needs improvement:  0
Easy pickings:  0                |                    UI/UX:  0
---------------------------------+------------------------------------

Comment (by BertrandBordage):

 The solution would be to partially include `admin/js/change_form.js` to
 the changelist view.

 I made a workaround for Django 1.9 (and probably all other versions).
 Create a static file `admin/js/change_list.js` containing this:
 {{{#!javascript
 // FIXME: Remove this file, it’s a workaround to
 https://code.djangoproject.com/ticket/26387

 (function($) {
     'use strict';
     $(document).ready(function() {
         $('.related-lookup').click(function(e) {
             e.preventDefault();
             var event = $.Event('django:lookup-related');
             $(this).trigger(event);
             if (!event.isDefaultPrevented()) {
                 showRelatedObjectLookupPopup(this);
             }
         });
     });
 })(django.jQuery);
 }}}
 Then add a `media` property to your admin class:
 {{{#!python
 from django.forms import Media

 class YourModelAdmin(ModelAdmin):
     […]

     # FIXME: Remove this workaround to
 https://code.djangoproject.com/ticket/26387
     @property
     def media(self):
         return super(YourModelAdmin,
                      self).media + Media(js=['admin/js/change_list.js'])
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/26387#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/073.ffb90859e5957a7de45fb8458b659743%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to