How do set default values in django for an HttpRequest.GET?
Posted
by Mike
on Stack Overflow
See other posts from Stack Overflow
or by Mike
Published on 2010-05-04T08:02:52Z
Indexed on
2010/05/04
8:08 UTC
Read the original article
Hit count: 242
I have a webpage that displays data based on a default date. The user can then change their view of the data by slecting a date with a date picker and clicking a submit button. I already have a variable set so that if no date is chosen, a default date is used.... so what's the problem? The problem comes if the user trys to type in the url page without a parameter... like so:
http://mywebpage/viewdata (example A)
instead of
http://mywebpage/viewdata?date= (example B)
I tried using:
if request.method == 'GET':
but apparently, even example A still returns true. I'm sure I'm doing some obvious beginner's mistake but I'll ask anyway... Is there a simpler way to handle example A other than passing the url to a string and checking the string for "?date="?
© Stack Overflow or respective owner