Django Query Error: How Do I Properly Query My Total Likes To Show In The Home Screen?
Solution 1:
The exception: Page not found (404) No BlogPost matches the given query.
is being raised by get_object_or_404
as it does exactly what the name says. If the BlogPost
with the supplied slug
in any of the views doesn't exist in the database, Django will raise an Http404
exception as you're witnessing.
Now, since we don't know the structure of your BlogPost
model, I can't really tell you where to change, all I can tell you is you need to make sure, the slug
is a unique field on each BlogPost
instance, othwerwise your code is working as one would expect.
EDIT
I had not seen the BlogPost
model, my bad, but the information is still relavant a BlogPost with such a slug
does not exist. So do a manual check, see what the slug arrives in the view(s) as, and then check manually either in DB or in your shell.
Post a Comment for "Django Query Error: How Do I Properly Query My Total Likes To Show In The Home Screen?"