我的用户模型中的 urls.py 文件有问题。当我访问 localhost:5000/users/ 时,我得到了预期的页面,但是当我转到 localhost:5000/users/1 时,我得到了一个页面,上面写着
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:5000/users/1
Using the URLconf defined in ng_blog.urls, Django tried these URL patterns, in this order:
^users/$
但我的 urls.py 似乎定义得当。
urlpatterns = patterns('',
url(
r'^$',
UserList.as_view(),
name='user_list'
),
url(
r'^(?P<username>\w+)/$',
UserDetail.as_view(),
name='user_detail'
),
)
根 urls.py 文件是
urlpatterns = patterns('',
url(r'^blog/$', include('blog.urls')),
url(r'^users/$', include('users.urls')),
)