Skip to content

Commit

Permalink
Merge pull request #51 from Naggafin/master
Browse files Browse the repository at this point in the history
fixed bug where `extra_context` was being truncated
  • Loading branch information
shinneider authored Mar 1, 2024
2 parents 967c2be + 40b1a49 commit bcaed11
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion django_admin_search/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ def changelist_view(self, request, extra_context=None):
"""
Append custom form to page render
"""
extra_context = extra_context or {}
if hasattr(self, 'search_form'):
self.advanced_search_fields = {}
self.search_form_data = self.search_form(request.GET.dict())
self.extract_advanced_search_terms(request.GET)
extra_context = {'asf': self.search_form_data}
extra_context.update({'asf': self.search_form_data})

return super().changelist_view(request, extra_context=extra_context)

Expand Down
8 changes: 5 additions & 3 deletions django_admin_search/templates/admin/custom_search_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
{{ full_result_count }} total{% endblocktrans %}{% else %}{% trans "Show all" %}{% endif %}</a>)
</span>
{% endif %}
{% for pair in cl.params.items %}
{% if pair.0 != search_var %}<input type="hidden" name="{{ pair.0 }}" value="{{ pair.1 }}"/>{% endif %}
{% endfor %}
{% if cl.params %}
{% for pair in cl.params.items %}
{% if pair.0 != search_var %}<input type="hidden" name="{{ pair.0 }}" value="{{ pair.1 }}"/>{% endif %}
{% endfor %}
{% endif %}

<div class="form_button_container">
{% block modal_search_button %}
Expand Down

0 comments on commit bcaed11

Please sign in to comment.