運行出錯了
點擊最新文章的第一篇,會報錯
IndexError at /blog/detail/23
list?index?out?of?range
Request Method: | GET |
---|---|
Request URL: | http://127.0.0.1:8000/blog/detail/23 |
Django Version: | 3.0.4 |
Exception Type: | IndexError |
Exception Value: | list?index?out?of?range |
Exception Location: | D:\python\lib\site-packages\django\db\models\query.py in __getitem__, line 296 |
Python Executable: | D:\python\python.exe |
Python Version: | 3.8.1 |
Python Path: | ['D:\\Webprojects\\django_introduction', ?'E:\\', ?'D:\\python\\python38.zip', ?'D:\\python\\DLLs', ?'D:\\python\\lib', ?'D:\\python', ?'D:\\python\\lib\\site-packages'] |
Server time: | Thu, 19 Mar 2020 06:29:09 +0000 |
????
2021-08-18
這個問題的原因應該是在做上一篇和下一篇的時候出現了問題,導致取文章的值的時候數組溢出了。
遍歷文章的下標應該去判斷等于所有文章長度-1
2020-03-23
23太多了,出界了