diff options
| author | Karen Tracey <kmtracey@gmail.com> | 2008-10-22 23:14:48 +0000 |
|---|---|---|
| committer | Karen Tracey <kmtracey@gmail.com> | 2008-10-22 23:14:48 +0000 |
| commit | 74997f95def1ed655f24bdd526aed1f8912fe646 (patch) | |
| tree | 709bdb396f7f4af51ab2238e3f56d8cc37b17362 /django | |
| parent | d7ebda8d08f0b50e5cda216d562f14701731164b (diff) | |
[1.0.X] Fixed #9252 -- Moved the try/except protecting against incorrect lookup params to where the error is now raised, and added a test for this case.
Backport of [9245] from trunk.
git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9246 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/admin/views/main.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/django/contrib/admin/views/main.py b/django/contrib/admin/views/main.py index c4970af53c..b450e89459 100644 --- a/django/contrib/admin/views/main.py +++ b/django/contrib/admin/views/main.py @@ -99,14 +99,7 @@ class ChangeList(object): def get_results(self, request): paginator = Paginator(self.query_set, self.list_per_page) # Get the number of objects, with admin filters applied. - try: - result_count = paginator.count - # Naked except! Because we don't have any other way of validating - # "params". They might be invalid if the keyword arguments are - # incorrect, or if the values are not in the correct type (which would - # result in a database error). - except: - raise IncorrectLookupParameters + result_count = paginator.count # Get the total number of objects, with no admin filters applied. # Perform a slight optimization: Check to see whether any filters were @@ -192,7 +185,15 @@ class ChangeList(object): lookup_params[key] = value.split(',') # Apply lookup parameters from the query string. - qs = qs.filter(**lookup_params) + try: + qs = qs.filter(**lookup_params) + # Naked except! Because we don't have any other way of validating "params". + # They might be invalid if the keyword arguments are incorrect, or if the + # values are not in the correct type, so we might get FieldError, ValueError, + # ValicationError, or ? from a custom field that raises yet something else + # when handed impossible data. + except: + raise IncorrectLookupParameters # Use select_related() if one of the list_display options is a field # with a relationship. |
