简体   繁体   中英

what did i do wrong while implementing slug url in django?

I am getting the following error after I modified the urls.py, views.py and models.py file in my blog application to accomodate a slug string in the url.

Reverse for 'post_detail' with keyword arguments '{'pk': 3}' not found. 1 pattern(s) tried: ['(?P[-\\w\\d]+),(?P\\d+)/$']

I am attaching the link to the github repository for the project here, as I don't have any idea what went wrong please let me know where to look. git repository

I don't see why you have a comma in your pattern, did you mean to use a slash?

'^(?P<slug>[-\w\d]+),(?P<pk>\d+)/$'
#                   ^ ??

Also, the error indicates you're passing only the 'pk' . However, now that that pattern has been updated with a 'slug' parameter, you need to pass this also.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM