[英]Django url redirect error
I have the following in my project urls: 我的项目网址中包含以下内容:
urlpatterns = patterns('',
url(r'^admin/', include(admin.site.urls)),
url(r'^$', include('myapp.urls')),
url(r'^login$', user_login, name='login'),
url(r'^logout$', user_logout, name='logout'),
)
and i had the following in my app urls: 而且我的应用程序网址中包含以下内容:
urlpatterns = patterns('',
url(r'^$', views.DefaultView.as_view(), name='default'),
url(r'^register/$', views.CustomerRegister, name='customerregister'),
)
The default view loads up fine but the Register url is not working. 默认视图可以正常加载,但是Register url不起作用。 I tried the following links:
我尝试了以下链接:
localhost:8000/
localhost:8000/register
url(r'^$', include('myapp.urls')),
should be url(r'', include('myapp.urls')),
url(r'^$', include('myapp.urls')),
应该是url(r'', include('myapp.urls')),
Note that the ^
matches the start of the string, and the $
matches the end of the string, so ^$
will only match an empty string (usually used for the index). 请注意,
^
匹配字符串的开头, $
匹配字符串的结尾,因此^$
仅匹配空字符串(通常用于索引)。 Similarly, notice the admin url does not end with a $
. 同样,请注意,管理网址的结尾不是
$
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.