ValueError when getting objects by id

后端 未结 4 1646
无人及你
无人及你 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 10:53

    In addition to the URL problem, you are not generating the right link in the first place - you refer to result.object.title but post.id in the template, which is why your URL contains 0 for the ID. I expect you mean result.id or result.object.id.

提交回复
热议问题