Printing Django QuerySet SQL with “”

后端 未结 3 759
难免孤独
难免孤独 2021-01-18 01:41

You can print a queryset\'s SQL as follows:

print str(queryset.query)

however, for some reason this removes quotation marks, so you get:

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-18 02:11

    If this is for debug purpose you should look into django-debug-toolbar that will show you all queries ran for any view you're looking at

提交回复
热议问题