I'm using django-guardian library to verify users permissions in an object level and I'm trying to verify that inside of the change_list_results.html template, NOTE : the same code worked just fine under change_list.html but for some reason it's not working for change_list_results.html.


here's my code, under change_list_results.html template :

{% for object in cl.result_list %}
{% get_obj_perms user for object as "context_var" %}
{% if 'college_admin' in context_var %}
{% endif %}
{% endfor %}

The user in {% get_obj_perms user for object as "context_var" %} is causing the error.


Failed lookup for key [user] in [{'True': True, 'False': False, 'None': None}, 
{'cl': <django.contrib.admin.views.main.ChangeList object at 0x7fa319ba0a00>,
 'result_hidden_fields': [], 'result_headers': [{'text': '<input type="checkbox"
 id="action-toggle">', 'class_attrib': ' class="action-checkbox-column"',
 'sortable': False}, {'text': 'generator', 'class_attrib': ' class="column-
__str__"', 'sortable': False}], 'num_sorted_fields': 0, 'results': [['<td 
class="action-checkbox"><input type="checkbox" name="_selected_action" value="26" 
class="action-select"></td>', '<th class="field-__str__"><a href="/generator
/generator/26/change/">الهندسة</a></th>'], ['<td class="action-checkbox"><input 
type="checkbox" name="_selected_action" value="25" class="action-select"></td>',
 '<th class="field-__str__"><a href="/generator/generator/25/change/">العلوم</a>
</th>']], 'csrf_token': <SimpleLazyObject: