Django的。关于重定向的困惑

时间:2013-12-25 10:06:31

标签: django

这是我的简化代码:
项目的网址:

from django.conf.urls import patterns, include, url
urlpatterns = patterns('',
    url(r'^to_app1/', include('app1.urls')),
    url(r'^to_app2/', include('app2.urls')),
)

app1的网址:

from django.conf.urls import *
from app1 import views
urlpatterns = patterns('',
    url(r'^$', views.app1Page, name='app1-page'),
    url(r'^action/', views.app1_to_app2, name='app1-to-app2-page'),
)

app2的网址:

from django.conf.urls import *
from app2 import views
urlpatterns = patterns('',
    url(r'^$', views.app2Page, name='app2-page'),
)

app1的观点:

def app1Page(request):
    return render(request, 'app1/app1page.html')

def app1_to_app2(request):
    # some actions going on here #
    return HttpResponseRedirect('/to_app2/')

app2的观点:

def app2Page(request):
    return render(request, 'app2/app2page.html')

所以,我在app1page.html上有一个按钮,它应该通过POST函数将数据发送到 to_app1 / action / url。最后它应该将我重定向到app2page.html,但事实并非如此。它给了我GET 127.0.0.1:8000/to_app2/ HTTP / 1.0 200 OK,但我留在同一页面(app1page.html)。

显然我遗漏了一些东西,有人可以向我指出吗?

0 个答案:

没有答案