Django 问题:使用 HttpResponseRedirect 需要帮助
我有一个名为 save_service_request 的视图。在代码末尾,它重定向到名为 send_confirmation_email 的视图。
def save_service_request(request):
try:
# some stuff
except:
return HttpResponseRedirect(reverse(service_order, args = [contact.client.pk , service_type]))
return HttpResponseRedirect(reverse(send_confirmation_email, args = [order.pk, service_type]))
现在我想用这个做点什么。如果我在页面上,
(r'^quote/service_order/(?P<client_id>\d+)/(?P<request_type>\d+)/$', views.service_order),
请使用 HttpResponseRedirect 转到 send_confirmation_email 视图。
但如果之前的url被调用了。
(r'^quote/service_order/edit_items/(?P<client_id>\d+)/(?P<request_type>\d+)/$', views.service_order2),
将其发送到此
return HttpResponseRedirect(reverse(delete_confirmation, args = [order.pk, service_type]))
这也许可以使用 if 语句。
I have a view called save_service_request. At the end of the code it redirects to a view called send_confirmation_email.
def save_service_request(request):
try:
# some stuff
except:
return HttpResponseRedirect(reverse(service_order, args = [contact.client.pk , service_type]))
return HttpResponseRedirect(reverse(send_confirmation_email, args = [order.pk, service_type]))
Now I want do something with this. If I am at the page
(r'^quote/service_order/(?P<client_id>\d+)/(?P<request_type>\d+)/
go to send_confirmation_email view using HttpResponseRedirect.
But if the url before was called.
(r'^quote/service_order/edit_items/(?P<client_id>\d+)/(?P<request_type>\d+)/
go send it to this
return HttpResponseRedirect(reverse(delete_confirmation, args = [order.pk, service_type]))
This maybe possible using if statements.
, views.service_order),
go to send_confirmation_email view using HttpResponseRedirect.
But if the url before was called.
go send it to this
This maybe possible using if statements.
, views.service_order2),
go send it to this
This maybe possible using if statements.
, views.service_order),go to send_confirmation_email view using HttpResponseRedirect.
But if the url before was called.
go send it to this
This maybe possible using if statements.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
next
属性:在
views.service_order
中在模板中:
在验证表单的视图中:
Use
next
attribute:In
views.service_order
In template:
In view which validates form: