django : using select_related and get_object_or_404 together

后端 未结 1 936
不思量自难忘°
不思量自难忘° 2020-12-22 22:16

Is there any way of using get_object_or_404 and select_related together or any other way to achieve the result of using these two together(except from putting it in try/exce

1条回答
  •  悲哀的现实
    2020-12-22 22:55

    Yes.

    obj = get_object_or_404(MyModel.objects.select_related(), whatever=whatever)
    

    0 讨论(0)
提交回复
热议问题