Django

Code

Changeset 3024

Show
Ignore:
Timestamp:
05/31/06 10:25:23 (2 years ago)
Author:
adrian
Message:

Fixed bug in admin where it would redirect infinitely if invalid lookup parameters were given in the URL. Refs #2024

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/contrib/admin/views/main.py

    r3018 r3024  
    3636SEARCH_VAR = 'q' 
    3737IS_POPUP_VAR = 'pop' 
     38ERROR_FLAG = 'e' 
    3839 
    3940# Text to display within change-list table cells if the value is blank. 
     
    558559        if self.params.has_key(PAGE_VAR): 
    559560            del self.params[PAGE_VAR] 
     561        if self.params.has_key(ERROR_FLAG): 
     562            del self.params[ERROR_FLAG] 
    560563 
    561564        self.order_field, self.order_type = self.get_ordering() 
     
    731734        cl = ChangeList(request, model) 
    732735    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') 
    734744    c = template.RequestContext(request, { 
    735745        'title': cl.title,