Django newbie.
我正在尝试将"id_numb"作为获取请求传递,这是 URL:mysite/?id_numb=1。但是,它不会进入第二个 if 语句。
if request.GET['id_numb']:
id_numb = request.GET['id_numb']
if id_numb == 1:
# doesn't make it here - never get to this code, even when 1 is passed
....different code
else:
....some code
else:
.... some other code
也许你可以试试
if request.GET['id_numb']:
id_numb2 = request.GET['id_numb']
id_numb = int(id_numb2)
if id_numb == 1:
# doesn't make it here - never get to this code, even when 1 is passed
....different code
else:
....some code
else:
.... some other code