[Fixed]-Works when I use post_id, but as soon as I change to slug it doesn't work…why?

1👍

Notice the \d+ in this line:

url(r'^post/(?P<slug>\d+)/vote/$', 'main.views.vote', name='vote'),

\d+ means that it only takes numbers

The regex for a slug should be like this:
url(r'^post/(?P<slug>[-\w]+)/vote/$', 'main.views.vote', name='vote'),

as suggested in this answer https://stackoverflow.com/a/27322151/4724196

Hope this helps!

Leave a comment