Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GET request not found

In my application, I have various articles users can create with a category field that I want to serve as a tagging system. On the left hand side of my application, I'd like these categories to be listed so users can filter by interest but I'm currently unable to get it working. The error I'm getting is listed below:

Using the URLconf defined in bitpoll.urls, Django tried these URL patterns, in this order:

^articles/ ^all/$
^articles/ ^get/(?P<article_id>\d+)/$
^articles/ ^category/(?P<article_category>\d+)/$
^admin/

The current URL, articles/category/electronics, didn't match any of these.

My code can be found on GitHub here and the location of the error is in /article/urls.py.

Clicking on a specific article in /article/templates/articles.html works just fine but it doesn't work for my categories and it seems to me like they're setup the exact same way.

like image 230
clo5ure Avatar asked May 29 '26 06:05

clo5ure


1 Answers

In your articles route the regex is looking for digits. Correct the regex to match any characters that can occur in your article_category field. For example, the \w matches any alphanumeric character and the underscore.

^articles/ ^category/(?P<article_category>\w+)/$
like image 93
garnertb Avatar answered May 31 '26 04:05

garnertb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!