#13659: Make the request accessible in callables used in ModelAdmin.list_display
---------------------------------+------------------------------------
     Reporter:  Sebastian Noack  |                    Owner:  Paulo
         Type:  New feature      |                   Status:  assigned
    Component:  contrib.admin    |                  Version:  dev
     Severity:  Normal           |               Resolution:
     Keywords:                   |             Triage Stage:  Accepted
    Has patch:  1                |      Needs documentation:  1
  Needs tests:  0                |  Patch needs improvement:  1
Easy pickings:  0                |                    UI/UX:  0
---------------------------------+------------------------------------

Comment (by dbartenstein):

 As callables in list_display don’t get the request object, is it safe to
 add the request object as attribute to the admin class object? In the
 callable it would then be possible to access the request via self.request
 to e.g. check if the current user has permission to edit the object.

 Code sample:
 {{{
 def changelist_view(self, request, extra_context=None):
     self.request = request  # Is it safe to store the request?
     return super().changelist_view(request, extra_context)

 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/13659#comment:13>
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/073.cbc8e741a3f7e4d8a1c2bb606c88121e%40djangoproject.com.

Reply via email to