Skip to content

Instantly share code, notes, and snippets.

@qoelet
Created June 1, 2012 01:25
Show Gist options
  • Save qoelet/2847884 to your computer and use it in GitHub Desktop.
Save qoelet/2847884 to your computer and use it in GitHub Desktop.
# Getting a GET value
pageNumber = int(request.GET.get('page', 1))
# But some doofus goes and change /?page=n, n to some weird char and ValueError
# Fixed
try:
pageNumber = int(request.GET.get('page', 1))
except ValueError:
pageNumber = 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment