环境:win10,Python3.7,Django2.2.15
找不到路由地址
查看大佬代码Django2_dailyfresh,发现多写了个反向解析(reverse)
# 获取登录后要跳转到的地址,默认跳转到首页
next_url = request.GET.get('next',reverse('goods:index')) # 获取不到next,默认返回商品首页
# 跳转到next_url
response = redirect(reverse(next_url)) # HttpResponseRedirect
正确写法如下
# 获取登录后要跳转到的地址,默认跳转到首页
next_url = request.GET.get('next',reverse('goods:index')) # 获取不到next,默认返回商品首页
# 跳转到next_url
response = redirect(next_url) # HttpResponseRedirect