ValueError when getting objects by id

后端 未结 4 1625
无人及你
无人及你 2021-01-23 10:19

I\'m trying to get data by id in my django app. The problem is that I don\'t know the kind of id the user will click on. I input the below codes in views.

Views

4条回答
  •  情话喂你
    2021-01-23 11:08

    You misplaced a closing parenthesis:

    url(r'^cribme/(?P\d+)/$', 'meebapp.views.cribdetail', name='cribdetail'),
    

    Note that the (?P .. ) group construct should include the \d+ characters you are trying to match. In your incorrect regular expression you define a group that doesn't include any matched characters, thus always the empty string ''.

提交回复
热议问题