Django error - matching query does not exist

后端 未结 4 1220
礼貌的吻别
礼貌的吻别 2020-12-24 11:25

I finally released my project to the production level and suddenly I have some issues I never had to deal with in the development phase.

When the users posts some ac

4条回答
  •  清酒与你
    2020-12-24 11:54

    Maybe you have no Comments record with such primary key, then you should use this code:

    try:
        comment = Comment.objects.get(pk=comment_id)
    except Comment.DoesNotExist:
        comment = None
    

提交回复
热议问题