Pass the queryset filters from the request into the object_rep.html template

master
blag 2020-05-24 02:46:19 -07:00
parent 247078c7e0
commit 00eb3fdb30
No known key found for this signature in database
GPG Key ID: 30870D32F59C5F40
2 changed files with 5 additions and 1 deletions

View File

@ -15,6 +15,7 @@ from django.http import HttpResponse
from django.shortcuts import render from django.shortcuts import render
from django.template.defaultfilters import capfirst from django.template.defaultfilters import capfirst
from django.utils.decorators import method_decorator from django.utils.decorators import method_decorator
from django.utils.six.moves.urllib.parse import urlencode
from django.views.decorators.http import require_POST from django.views.decorators.http import require_POST
from adminsortable.fields import SortableForeignKey from adminsortable.fields import SortableForeignKey
@ -236,6 +237,8 @@ class SortableAdmin(SortableAdminBase, ModelAdmin):
else: else:
context = self.admin_site.each_context(request) context = self.admin_site.each_context(request)
filters = urlencode(self.get_querystring_filters(request))
context.update({ context.update({
'title': u'Drag and drop {0} to change display order'.format( 'title': u'Drag and drop {0} to change display order'.format(
capfirst(verbose_name_plural)), capfirst(verbose_name_plural)),
@ -246,6 +249,7 @@ class SortableAdmin(SortableAdminBase, ModelAdmin):
'sortable_by_class': sortable_by_class, 'sortable_by_class': sortable_by_class,
'sortable_by_class_is_sortable': sortable_by_class_is_sortable, 'sortable_by_class_is_sortable': sortable_by_class_is_sortable,
'sortable_by_class_display_name': sortable_by_class_display_name, 'sortable_by_class_display_name': sortable_by_class_display_name,
'filters': filters,
'jquery_lib_path': jquery_lib_path, 'jquery_lib_path': jquery_lib_path,
'csrf_cookie_name': getattr(settings, 'CSRF_COOKIE_NAME', 'csrftoken'), 'csrf_cookie_name': getattr(settings, 'CSRF_COOKIE_NAME', 'csrftoken'),
'csrf_header_name': getattr(settings, 'CSRF_HEADER_NAME', 'X-CSRFToken'), 'csrf_header_name': getattr(settings, 'CSRF_HEADER_NAME', 'X-CSRFToken'),

View File

@ -2,6 +2,6 @@
<form> <form>
<input name="pk" type="hidden" value="{{ object.pk|unlocalize }}" /> <input name="pk" type="hidden" value="{{ object.pk|unlocalize }}" />
<a href="{% url opts|admin_urlname:'do_sorting' object.model_type_id|unlocalize %}" class="admin_sorting_url"><i class="fa fa-{% if forloop.first %}sort-desc{% elif forloop.last %}sort-asc{% else %}sort{% endif %}"></i> {{ object }}</a> <a href="{% url opts|admin_urlname:'do_sorting' object.model_type_id|unlocalize %}{% if filters %}?{{ filters }}{% endif %}" class="admin_sorting_url"><i class="fa fa-{% if forloop.first %}sort-desc{% elif forloop.last %}sort-asc{% else %}sort{% endif %}"></i> {{ object }}</a>
{% csrf_token %} {% csrf_token %}
</form> </form>