In Django - Overriding get_form to customize admin forms based on request the problem is to select a different form based on the permissions of the user in the request object by hooking the get_form() method.
I would like to actually invoke a method on the object during iteration that uses the request context to output some information.
The documentation lists four ways to hook the form display.
But the function signatures don't include the request object. If they did, you could write something like (note that request is not in fact an argument):
class CustomAdmin(admin.ModelAdmin):
list_display = [ 'name', 'user_specific', ]
#
def user_specific(self, obj, request):
return obj.func1(request)
#
output.short_description = 'UserSpecific'
Overriding get_form() would not be thread safe if used to store the state... So what would be the best way?