Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed bug in admin where it would redirect infinitely if invalid look…

…up parameters were given in the URL. Refs #2024

git-svn-id: http://code.djangoproject.com/svn/django/trunk@3024 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 2543d0ae9373eeea9eebce3d48df930b3220a506 1 parent ea59344
@adrianholovaty adrianholovaty authored
View
10 django/contrib/admin/templates/admin/invalid_setup.html
@@ -0,0 +1,10 @@
+{% extends "admin/base_site.html" %}
+{% load i18n %}
+
+{% block breadcrumbs %}<div class="breadcrumbs"><a href="../../">{% trans 'Home' %}</a> &rsaquo; {{ 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 %}
View
12 django/contrib/admin/views/main.py
@@ -35,6 +35,7 @@
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 @@ def __init__(self, request, model):
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,
Please sign in to comment.
Something went wrong with that request. Please try again.