easy_c0mpany80 easy_c0mpany80 - 1 year ago 184
Python Question

Django - No Post matches the given query

Ive been building a blog via a tutorial in the book 'django by example'.

Im working on the part where a blog post can be shared via email, everything works fine when I run it until I click the 'share post' link under an entry and then I get the following 404

Page not found (404)
Request Method: GET
Request URL:
Raised by: blog.views.post_share
No Post matches the given query.

My understanding is that this is telling me the post can't be found from the db right? Well I have 3 test posts all visible in django admin and they are published and when I login via django shell I can see that all 3 posts are there too.

Ive gone over my code multiple times now and have the code that came with the book and cannot see anything amiss, here are the forms, views, models and urls files from the app of my project


Ive read some other threads here from people who had similar problems and tried moving my url patterns around a bit but that hasn't helped.

this is a screen grab of what the page should return when I try to share it too

screen grab

this is the full local url that is returning a 404 btw

any help would be appreciated as Im stumped!

Answer Source

You are having a simple typo in your code:

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

I guess it should be 'published'.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download