开发者

django : using select_related and get_object_or_404 together

开发者 https://www.devze.com 2023-03-19 01:42 出处:网络
Is there any way of using get_object_or_404 and select_related together or any oth开发者_运维知识库er way to achieve the result of using these two together(except from putting it in try/except)?? Yes.

Is there any way of using get_object_or_404 and select_related together or any oth开发者_运维知识库er way to achieve the result of using these two together(except from putting it in try/except)??


Yes.

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

精彩评论

暂无评论...
验证码 换一张
取 消