magic-removal: Merged to [2427]

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2428 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2006-02-28 00:13:06 +00:00
parent 735e8a56bd
commit ae19fb4c61
2 changed files with 12 additions and 9 deletions

View File

@ -915,7 +915,10 @@ class USStateField(TextField):
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 File

@ -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,