Reputation: 387
I am overrding the admin ChangeList
class and i am adding my own function there which requires request object like this
class MyChangeList(ChangeList):
def sample(self, request):
test = request.session["myvar"]
return test
in the inclusion tag i need to use like this
@register.inclusion_tag("admin/change_list_results.html")
def my_result_list(cl):
"""
Displays the headers and data list together
"""
myvar = cl.sample()
num_sorted_fields = 0
How can i do that?
Upvotes: 2
Views: 865
Reputation: 862
Pass takes_context=True
to tag decorator.
@register.inclusion_tag("admin/change_list_results.html", takes_context=True)
def my_result_list(context, cl):
"""
Displays the headers and data list together
"""
myvar = cl.sample(context['request'])
num_sorted_fields = 0
Upvotes: 3