获取请求参数未触发 if 语句在 Django 中



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

相关内容

  • 没有找到相关文章

最新更新