Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

magic-removal: Merged to [2427]

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2428 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit ae19fb4c61526c41610f8219bd1eb480de1fb48c 1 parent 735e8a5
@adrianholovaty adrianholovaty authored
Showing with 12 additions and 9 deletions.
  1. +4 −1 django/forms/__init__.py
  2. +8 −8 django/views/generic/list_detail.py
View
5 django/forms/__init__.py
@@ -915,7 +915,10 @@ def isValidUSState(self, field_data, all_data):
raise validators.CriticalValidationError, e.messages
def html2python(data):
- return data.upper() # Should always be stored in upper case
+ if data:
+ return data.upper() # Should always be stored in upper case
+ else:
+ return None
html2python = staticmethod(html2python)
class CommaSeparatedIntegerField(TextField):
View
16 django/views/generic/list_detail.py
@@ -37,22 +37,22 @@ def object_list(request, queryset, paginate_by=None, allow_empty=False,
model = queryset.model
if paginate_by:
paginator = ObjectPaginator(queryset, paginate_by)
- page = request.GET.get('page', 0)
+ page = request.GET.get('page', 1)
try:
- object_list = paginator.get_page(page)
- except InvalidPage:
- if page == 0 and allow_empty:
+ page = int(page)
+ object_list = paginator.get_page(page - 1)
+ except (InvalidPage, ValueError):
+ if page == 1 and allow_empty:
object_list = []
else:
raise Http404
- page = int(page)
c = RequestContext(request, {
'object_list': object_list,
'is_paginated': paginator.pages > 1,
'results_per_page': paginate_by,
- 'has_next': paginator.has_next_page(page),
- 'has_previous': paginator.has_previous_page(page),
- 'page': page + 1,
+ 'has_next': paginator.has_next_page(page - 1),
+ 'has_previous': paginator.has_previous_page(page - 1),
+ 'page': page,
'next': page + 1,
'previous': page - 1,
'pages': paginator.pages,
Please sign in to comment.
Something went wrong with that request. Please try again.