From b9db782d51fc6d02b09b790ea33d8ccbe94c404b Mon Sep 17 00:00:00 2001 From: iryabykin Date: Sun, 24 May 2020 02:45:43 +0300 Subject: [PATCH] Navigation back from Detail to List with filters preserved moreover, now it is possible to get back from any related model Detail view inside the iframe --- simpleui/templates/admin/change_form.html | 2 +- simpleui/templatetags/simpletags.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/simpleui/templates/admin/change_form.html b/simpleui/templates/admin/change_form.html index 43b7e822..19ee5523 100644 --- a/simpleui/templates/admin/change_form.html +++ b/simpleui/templates/admin/change_form.html @@ -108,7 +108,7 @@ el: '.page-header', methods: { goBack: function () { - window.location.href = '{% get_model_url %}' + window.location.href = '{% get_previous_url %}' } } }) diff --git a/simpleui/templatetags/simpletags.py b/simpleui/templatetags/simpletags.py index 32bd39dc..709c3570 100644 --- a/simpleui/templatetags/simpletags.py +++ b/simpleui/templatetags/simpletags.py @@ -478,3 +478,7 @@ def get_boolean_choices(): ('True', _('Yes')), ('False', _('No')) ) + +@register.simple_tag(takes_context=True) +def get_previous_url(context): + return context.request.META.get('HTTP_REFERER')