2017-07-23 51 views
0

我使用Windows 10,Django的1.11蟒蛇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

我從舊的listview中得到一個有效的網頁。

我試過清除緩存並使用不同的瀏覽器。

我試圖重新啓動和重新啓動服務器

python -B manage.py runserver 

我不知所措我爲什麼一直使用舊代碼來渲染頁面。

回答

0

嘗試刪除所有* .pyc文件。在Linux命令是:find . -type f -name '*.o' -exec rm {} +,對不起,但對於我現在不是。

+0

我試過在虛擬環境中搜索所有.pyc文件並刪除它們。不幸的是,它仍然顯示代碼被緩存在某處,因爲我仍然可以成功地展示網址/無論/場地/本身不會丟失我期待的模板錯誤。 –

+0

我不確定,但在您的成功請求中沒有關閉斜線,可能會有所幫助 –

0

您從ListView繼承您的看法。您可能需要將其更改爲DetailView

class VenueDetailView(DetailView): 

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

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

\w+ - >\d+

\w匹配任何字母數字字符和下劃線,即設置[A-ZA-Z0-9_ ]。

\d只匹配數字。

0

清除會話的控制檯命令有助於爲我解決問題。謝謝您的幫助。

python manage.py clearsessions