Reputation: 107092
I would like to add a bit of information to a certain change_list admin page. The info is taken from a queryset on a different model than that presented in this template. How do I go about doing this?
Upvotes: 1
Views: 814
Reputation: 107092
Use a Custom Template Tag - you can fetch and use anything in it.
Upvotes: 0
Reputation: 129
Try to rewrite changelist_view
function in your admin class:
class MyModelAdmin(admin.ModelAdmin):
# .....
def changelist_view(self, request, extra_context=None):
extra = {'foo': bar}
extra.update(extra_context or {})
return super(MyModelAdmin, self).changelist_view(request, extra_context=extra)
# .....
Upvotes: 4
Reputation: 2659
You can create a custom context processor. This allows you to expose a variable to the whole application. It works on pages rendered using RequestContext, tried this with the admin pages and it works.
Upvotes: 1