背景信息:我有3个应用 A,B和C
每个人都有views.py和urls.py文件
views.py
A有do_Ax(请求,xpto),do_Ay(请求,xpto),do_Az(请求,xpto)
B有do_Bx(请求),do_By(请求),do_Bz(请求)
C有do_Cx(request,xpto),do_Cy(request,xpto),do_Cz(request,xpto)
urls.py 甲
urlpatterns = patterns('',
url(r'^A_x/$', views.do_Ax, name='A_x'),
url(r'^A_y/$', views.do_Ay, name='A_y'),
url(r'^A_z/$', views.do_Az, name='A_z'),
乙
urlpatterns = patterns('',
url(r'^B_x/$', views.do_Bx, name='B_x'),
url(r'^B_y/$', views.do_By, name='B_y'),
url(r'^B_z/$', views.do_Bz, name='B_z'),
C
urlpatterns = patterns('',
url(r'^C_x/$', views.do_Cx, name='C_x'),
url(r'^C_y/$', views.do_Cy, name='C_y'),
url(r'^C_z/$', views.do_Cz, name='C_z'),
我的全球应用程序的入口点是通过B.在那里,我检查了一些东西,并想用新参数 REDIRECT 到A或C视图的正确方法... 有没有办法可以实现这个目标?
我尝试了一种n00b方法,但是我收到了一个SuspiciousOperation异常(“不安全的重定向到带方案的网址......”)
重要: 我还是一个名为 top 的“父”应用,其中包含以下urls.py:
urlpatterns = patterns('',
url(r'^A/', include('apps.top.A.urls', namespace="A")),
url(r'^B/', include('apps.top.B.urls', namespace="B")),
url(r'^C/', include('apps.top.C.urls', namespace="C")),
)
请注意>>>>> XPTO 是一个对象!!!!不是文字价值! <<<<<<<<
答案 0 :(得分:0)
from django.core.urlresolvers import reverse
from django import shortcuts
def do_Bx(request):
# do some tests here and whatever
xpto = whatever
url = reverse("A_x", args=[xpto])
return shortcuts.redirect(url)
答案 1 :(得分:0)