DjangoThe database processing is better than a black box. Which of the following operations is completely encapsulated by Django Orm?ProgramThe speed is slow, or you don't know the process in it when you want to debug it. This is a very depressing thing for us. Most programmers have an amazing mentality, they all want to see how it is actually executed. Don't worry. There is a solution below to solve this problem, so you can clearly see it.Django ORMIs the process of executing SQL statements, which is also a number of programs we write.
Specific steps: If you want to knowDjango prints SQL statements, You can see
Here we useDjango MiddlewareThe process_response (self, request, response) method of, the following isCode:
From Django. DB import connection
Def process_response (self, request, response ):
For SQL in connection. queries:
Print SQL
Return response
If you use the built-in Django server, you can see the result in shell.
With this method, you can understand the psychology of running SQL statements on Django.
If you are familiar with Django, we recommend you buy a python host to practice it ..
OriginalArticlePlease note that it is reproduced from Old Wang python. The address of this article is:Http://www.cnpythoner.com/post/118.html
Author: Lao Wang @Python Python tutorial
Old Wang Python provides pythn-relatedPython books, Django tutorial andPython downloadHope you will like it!