【问】django中视图转换

mysite.url.py

urlpatterns = patterns('mysite.video.views',
    #(r'^static/(?P<path>.*)$', 'django.views.static.serve',
    #{'document_root': settings.MEDIA_ROOT}),
    # Example:
    (r'^$', 'index'),
    # (r'^mysite/', include('mysite.foo.urls')),
    url(r'^video/', include('mysite.video.urls')),

    # Uncomment the admin/doc line below to enable admin documentation:
    # (r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    (r'^admin/', include(admin.site.urls)),
)

mysite.video.url.py

urlpatterns = patterns('',
    (r'^static/(?P<path>.*)$', 'django.views.static.serve',
    {'document_root': settings.MEDIA_ROOT}),
#    (r'^js/(?P<path>.*)$', 'django.views.static.serve',
#    {'document_root': "/var/www/mysite/static/js"}),
#    (r'^image/(?P<path>.*)$', 'django.views.static.serve',
#    {'document_root': "/var/www/mysite/static/image"}),

    url(r'^$', index, name="index"),
    url(r'^login/', login, name="login"),
    url(r'^register', register, name="register"),
    url(r'^logout', logout, name="logout"),
    url(r'^setting/', setting, name="setting"),
    url(r'^setserver/', setserver, name="setserver"),
    url(r'^setcamera/', setcamera, name="setcamera"),
    url(r'^history/', history, name="history"),
    url(r'^live/', live, name="live"),
    url(r'^replay/', replay, name="replay"),
    url(r'^config/', config, name="config"),
)

视图中HttpResponseRedirect("live")或者超链接时,产生的url是http://localhost/mysite/video/live/并且页面显示不全

视图中HttpResponseRedirect("/video/live")或者超链接也加/video前缀时,产生的url是http://localhost/video/live/并且页面显示全

why?

posted @ 2012-05-06 09:54  lidan  阅读(312)  评论(0编辑  收藏  举报