mirror of https://github.com/django/django.git
Fixed bug in admin where it would redirect infinitely if invalid lookup parameters were given in the URL. Refs #2024
git-svn-id: http://code.djangoproject.com/svn/django/trunk@3024 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
ea59344d72
commit
2543d0ae93
|
@ -0,0 +1,10 @@
|
|||
{% extends "admin/base_site.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block breadcrumbs %}<div class="breadcrumbs"><a href="../../">{% trans 'Home' %}</a> › {{ title }}</div>{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<p>{% trans "Something's wrong with your database installation. Make sure the appropriate database tables have been created, and make sure the database is readable by the appropriate user." %}</p>
|
||||
|
||||
{% endblock %}
|
|
@ -35,6 +35,7 @@ ORDER_TYPE_VAR = 'ot'
|
|||
PAGE_VAR = 'p'
|
||||
SEARCH_VAR = 'q'
|
||||
IS_POPUP_VAR = 'pop'
|
||||
ERROR_FLAG = 'e'
|
||||
|
||||
# Text to display within change-list table cells if the value is blank.
|
||||
EMPTY_CHANGELIST_VALUE = '(None)'
|
||||
|
@ -557,6 +558,8 @@ class ChangeList(object):
|
|||
self.params = dict(request.GET.items())
|
||||
if self.params.has_key(PAGE_VAR):
|
||||
del self.params[PAGE_VAR]
|
||||
if self.params.has_key(ERROR_FLAG):
|
||||
del self.params[ERROR_FLAG]
|
||||
|
||||
self.order_field, self.order_type = self.get_ordering()
|
||||
self.query = request.GET.get(SEARCH_VAR, '')
|
||||
|
@ -730,7 +733,14 @@ def change_list(request, app_label, model_name):
|
|||
try:
|
||||
cl = ChangeList(request, model)
|
||||
except IncorrectLookupParameters:
|
||||
return HttpResponseRedirect(request.path)
|
||||
# Wacky lookup parameters were given, so redirect to the main
|
||||
# changelist page, without parameters, and pass an 'invalid=1'
|
||||
# parameter via the query string. If wacky parameters were given and
|
||||
# the 'invalid=1' parameter was already in the query string, something
|
||||
# is screwed up with the database, so display an error page.
|
||||
if ERROR_FLAG in request.GET.keys():
|
||||
return render_to_response('admin/invalid_setup.html', {'title': _('Database error')})
|
||||
return HttpResponseRedirect(request.path + '?' + ERROR_FLAG + '=1')
|
||||
c = template.RequestContext(request, {
|
||||
'title': cl.title,
|
||||
'is_popup': cl.is_popup,
|
||||
|
|
Loading…
Reference in New Issue