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')