Ticket #6903: 6903.r16617.diff
File 6903.r16617.diff, 2.6 KB (added by , 13 years ago) |
---|
-
django/contrib/admin/options.py
813 820 # Figure out where to redirect. If the user has change permission, 814 821 # redirect to the change-list page for this object. Otherwise, 815 822 # redirect to the admin index. 816 if self.has_change_permission(request, None): 823 if self.has_change_permission(request, None) and 'HTTP_REFERER' in request.POST: 824 return HttpResponseRedirect(request.POST['HTTP_REFERER']) 825 elif self.has_change_permission(request, None): 817 826 return HttpResponseRedirect('../') 818 827 else: 819 828 return HttpResponseRedirect('../../../') … … 979 988 "The 'change' admin view for this model." 980 989 model = self.model 981 990 opts = model._meta 991 HTTP_REFERER = None 982 992 983 993 obj = self.get_object(request, unquote(object_id)) 984 994 … … 1033 1043 queryset=inline.queryset(request)) 1034 1044 formsets.append(formset) 1035 1045 1046 if 'HTTP_REFERER' in request.META: 1047 HTTP_REFERER = request.META['HTTP_REFERER'] 1048 1036 1049 adminForm = helpers.AdminForm(form, self.get_fieldsets(request, obj), 1037 1050 self.get_prepopulated_fields(request, obj), 1038 1051 self.get_readonly_fields(request, obj), … … 1059 1072 'inline_admin_formsets': inline_admin_formsets, 1060 1073 'errors': helpers.AdminErrorList(form, formsets), 1061 1074 'app_label': opts.app_label, 1075 'HTTP_REFERER': HTTP_REFERER, 1062 1076 } 1063 1077 context.update(extra_context or {}) 1064 1078 return self.render_change_form(request, context, change=True, obj=obj) -
django/contrib/admin/templates/admin/change_form.html
37 37 <form {% if has_file_field %}enctype="multipart/form-data" {% endif %}action="{{ form_url }}" method="post" id="{{ opts.module_name }}_form">{% csrf_token %}{% block form_top %}{% endblock %} 38 38 <div> 39 39 {% if is_popup %}<input type="hidden" name="_popup" value="1" />{% endif %} 40 {% if HTTP_REFERER %}<input type="hidden" name="HTTP_REFERER" value="{{ HTTP_REFERER }}" />{% endif %} 40 41 {% if save_on_top %}{% submit_row %}{% endif %} 41 42 {% if errors %} 42 43 <p class="errornote">