正在评估旧的列表视图

时间:2017-07-23 10:24:34

标签: django python-3.4

我使用的是Windows 10,django 1.11 python 3.4 ` http://127.0.0.1:8000/venues/16165/

在url.py中

url(r'^venues/(?P<pk>\w+)/$', VenueDetailView.as_view()),
在views.py中

class VenueDetailView(ListView):
#     template_name = 'venues_list.html'
    queryset = TestVenue.objects.all()

当我输入网址时

Page not found (404)
Request Method: GET
Request URL:    http://127.0.0.1:8000/venues/
Using the URLconf defined in bioskop.urls, Django tried these URL patterns, in this order:
^admin/
^$
^venues/(?P<pk>\w+)/$
^about/$
^contact/$
The current path, venues/, didn't match any of these.

如果我输入http://127.0.0.1:8000/venues/asdlkfj;akdjf

我从旧的列表视图中获得了有效的网页。

我已尝试清除缓存并使用其他浏览器。

我尝试重启并重启服务器

python -B manage.py runserver

我不知道为什么它一直使用旧代码来呈现页面。

2 个答案:

答案 0 :(得分:0)

您将从ListView继承您的观点。您可能需要将其更改为DetailView

class VenueDetailView(DetailView):

此外,您需要更改您的网址

url(r'^venues/(?P<pk>\d+)/$', VenueDetailView.as_view()),

\w+ - &gt; \d+

\w匹配任何字母数字字符和下划线,即设置[a-zA-Z0-9 _]。

\d仅匹配数字。

答案 1 :(得分:0)

清除会话的控制台命令有助于我解决问题。谢谢你的帮助。

python manage.py clearsessions