Skip to main content
 首页 » 编程设计

python之Django 网址无效

2024年10月01日29zfyouxi

每当我尝试访问该网站时,总是收到 404 错误。

这是我名为 userprofile 的应用程序中的 urls.py:

urlpatterns = [ 
    url(r'ˆ$', views.index, name = 'index') 
] 

这些是我的 urls.py:

from userprofile import urls 
 
 
urlpatterns = [ 
    url(r'^admin/', admin.site.urls), 
    url(r'ˆusers/', include('userprofile.urls')), 
] 

这是我的 views.py:

def index(request): 
    return HttpResponse("Hello, world. You're at the polls index.") 

我在控制台中没有收到任何错误。

Traceback: 
Not Found: /users/ 
[11/Jun/2017 17:17:47] "GET /users/ HTTP/1.1" 404 2036 

我试过/users/

请您参考如下方法:

您使用的是不同但看起来相似的字符,而不是正则表达式行起始字符:

ˆ 

代替:

^ 

>>> 'ˆ' == '^' 
False