Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Adrian Holovaty authored May 31, 2006
10  django/contrib/admin/templates/admin/invalid_setup.html
... ...
@@ -0,0 +1,10 @@
  1
+{% extends "admin/base_site.html" %}
  2
+{% load i18n %}
  3
+
  4
+{% block breadcrumbs %}<div class="breadcrumbs"><a href="../../">{% trans 'Home' %}</a> &rsaquo; {{ title }}</div>{% endblock %}
  5
+
  6
+{% block content %}
  7
+
  8
+<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>
  9
+
  10
+{% endblock %}
12  django/contrib/admin/views/main.py
@@ -35,6 +35,7 @@
35 35
 PAGE_VAR = 'p'
36 36
 SEARCH_VAR = 'q'
37 37
 IS_POPUP_VAR = 'pop'
  38
+ERROR_FLAG = 'e'
38 39
 
39 40
 # Text to display within change-list table cells if the value is blank.
40 41
 EMPTY_CHANGELIST_VALUE = '(None)'
@@ -557,6 +558,8 @@ def __init__(self, request, model):
557 558
         self.params = dict(request.GET.items())
558 559
         if self.params.has_key(PAGE_VAR):
559 560
             del self.params[PAGE_VAR]
  561
+        if self.params.has_key(ERROR_FLAG):
  562
+            del self.params[ERROR_FLAG]
560 563
 
561 564
         self.order_field, self.order_type = self.get_ordering()
562 565
         self.query = request.GET.get(SEARCH_VAR, '')
@@ -730,7 +733,14 @@ def change_list(request, app_label, model_name):
730 733
     try:
731 734
         cl = ChangeList(request, model)
732 735
     except IncorrectLookupParameters:
733  
-        return HttpResponseRedirect(request.path)
  736
+        # Wacky lookup parameters were given, so redirect to the main
  737
+        # changelist page, without parameters, and pass an 'invalid=1'
  738
+        # parameter via the query string. If wacky parameters were given and
  739
+        # the 'invalid=1' parameter was already in the query string, something
  740
+        # is screwed up with the database, so display an error page.
  741
+        if ERROR_FLAG in request.GET.keys():
  742
+            return render_to_response('admin/invalid_setup.html', {'title': _('Database error')})
  743
+        return HttpResponseRedirect(request.path + '?' + ERROR_FLAG + '=1')
734 744
     c = template.RequestContext(request, {
735 745
         'title': cl.title,
736 746
         'is_popup': cl.is_popup,

0 notes on commit 2543d0a

Please sign in to comment.
Something went wrong with that request. Please try again.