Django - 没有帖子匹配给定的查询

问题描述:

我一直在通过教程在书籍'django by example'建立一个博客。Django - 没有帖子匹配给定的查询

IM在其中一个博客帖子可以通过电子邮件共享的部分工作,一切工作正常,当我运行它,直到我点击一个条目下的“股后”链接,然后我得到以下404

Page not found (404) 
Request Method: GET 
Request URL: http://127.0.0.1:8000/blog/1/share/ 
Raised by: blog.views.post_share 
No Post matches the given query. 

我的理解是,这是告诉我无法从db中找到帖子吧?那么我有3个测试帖子都可以在django admin中看到,他们已经发布,当我通过django shell登录时,我可以看到所有3个帖子都在那里。

伊夫走了过来我的代码现在多次,并有随书附带的代码并不能看到任何不对劲,这里是从我的项目的应用形式,意见,模型和URL文件

https://github.com/davejonesbkk/mysite/blob/master/mysite/blog/forms.py 
https://github.com/davejonesbkk/mysite/blob/master/mysite/blog/views.py 
https://github.com/davejonesbkk/mysite/blob/master/mysite/blog/urls.py 
https://github.com/davejonesbkk/mysite/blob/master/mysite/blog/models.py 

我从有类似问题的人那里阅读了其他一些主题,并尝试过移动我的url模式,但这没有帮助。

这是当我尝试共享它的页面应该返回什么屏幕抓取太

screen grab

这是返回404 BTW

http://127.0.0.1:8000/blog/1/share/ 

全部本地网址任何帮助将不胜感激,因为我难倒!

+1

很难说没有视图的代码。 –

+0

你的意思是我的views.py?它在这里https://github.com/davejonesbkk/mysite/blob/master/mysite/blog/views.py –

你在你的代码一个简单的拼写错误:

post = get_object_or_404(Post, id=post_id, status='pubished') 

我想这应该是'published'

+0

dammit!谢谢! :) –