[Answered ]-404 Error "No Blog entry found matching the query" Django admin issue

1đź‘Ť

âś…

Django’s ulrpattern regex’s are greedy, i.e. they must match exactly.

So visiting the url 127.0.0.1:8000/admin will not direct you to the admin section, whose regex is r'^admin/'. You need to visit: 127.0.0.1:8000/admin/ (note the final /).

The reason you get the error “No Blog entry found matching the query” is because Django thinks /admin must be and attempt to fulfill r'^(?P<slug>\S+)$' for views.BlogDetail.as_view() (who’s regex you should modify to include a final /. e.g. r'^(?P<slug>\S+)/' and perhaps drop the $ too–why specify an ending?

Also, why are you using \S vs. \w?

1đź‘Ť

It’s a combination of issues. You’ve entered in the URL http://127.0.0.1/admin which will not match the regex r'^admin/'. Based on the error message, it almost looks like your BlogDetail view is getting called, so the URL routing has to be skipping the admin url.

Add the trailing slash to your requested URL and it should work.

I haven’t tested this, it’s just off the top of my head.

👤OozeMeister

Leave a comment