regular expression error in DJango trying to find index numbers on blog.html

前端 未结 1 457
野的像风
野的像风 2021-01-29 03:46

I have the following error while trying to load up specific index numbers (relating to blog posts) using Django.

The erroneous code is below - can anyo

相关标签:
1条回答
  • 2021-01-29 04:21

    The problem is that you are confused between the old regex-based URL mechanism and the new path-based one. If you use path, you should use the new special syntax:

    path('<int:pk>', DetailView.as_view(...))
    

    whereas if you want to use regexes, you should use the old url function (or the new alias, re_path):

    url(r'(?P<pk>\d+)', DetailView.as_view(...))
    
    0 讨论(0)
提交回复
热议问题