[Answer]-How to add a string (title) at the end of the url with Django?

1πŸ‘

βœ…

The title in the URL is part of the pattern, which may or may not be matched against the document slug in the view.

Something like:

url(r'^guideline/(?P<id>\d+)/(?P<slug>[-\w]+)/$', perma_post, name="cv_perma")

Then you could look for an object with both id and slug, or just the id and redirect to the correct URL if the slug does not match -which is what Stackoverflow does.

πŸ‘€jminuscula

Leave a comment