#16257: contrib:admin dynamic list_display_links support
-------------------------------------------------+-------------------------
 Reporter:  graveyboat                           |          Owner:  nobody
     Type:  New feature                          |         Status:  new
Milestone:                                       |      Component:
  Version:  1.3                                  |  contrib.admin
 Keywords:  list_display override dynamic admin  |       Severity:  Normal
Has patch:  0                                    |   Triage Stage:
    UI/UX:  0                                    |  Unreviewed
                                                 |  Easy pickings:  0
-------------------------------------------------+-------------------------
 Ticket #14206 created a very useful way to allow programmers to override
 list_display at runtime by using a new function get_list_display instead
 of accessing self.list_display.  Unfortunately, it potentially causes an
 issue with list_display_links.

 If list_display_links is not set in the ModelAdmin instance, currently the
 first field after 'action_checkbox' in list_display becomes
 list_display_links.  Since get_list_display happens after
 list_display_links is set, there is a potential that what is returned from
 get_list_display no longer contains the field in list_display_links.  Take
 the following for example:

 {{{
 class DynamicListDisplayChildAdmin(admin.ModelAdmin):
     list_display = ('name', 'parent')

     def get_list_display(self, request):
         my_list_display = list(self.list_display)
         if request.user.username == 'noparents':
             my_list_display.remove('name')

         return my_list_display
 }}}

 In this case, list_display_links would be ['name'], but 'name' is no
 longer in the list_display passed to the ChangeList instance.  Basically,
 the fix is to create a get_list_display_links method that is capable of
 checking list_display if necessary.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/16257>
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to