Django objects. all (), objects. get (), objects. filter (), djangoobjects. all
Ret = UserInfo. objects. all () all returns the QuerySet object. The program does not actually execute SQL statements in the database to query data, but supports iteration. You can use the for loop to obtain data. Ret = UserInfo. objects. get (id = '1') get returns the Model object and the type is list. This means that the get method will directly execute the SQL statement to obtain the data ret = UserInfo. objects. filter () is similar to get, but supports more powerful query functions.
Supplement:
When querySet is selected as a condition, filter indicates = and exclude indicates! =.
QuerySet. distinct () deduplication
_ Exact is exactly like 'aaa'
_ Iexact is exact equal to ignoring the upper and lower case ilike 'aaa'
_ Contains include like '% aaa %'
_ Icontains indicates that ilike '% aaa %' is case-insensitive. However, for sqlite, the effect of contains is equivalent to that of icontains.
_ Gt greater
_ Gte greater than or equal
_ Lt is less
_ Equal to or less than lte
_ In exists in a list range.
_ Startswith starts...
_ Istartswith starts with... and ignores case sensitivity.
_ Endswith ends...
_ Iendswith ends with..., case insensitive
_ Range is within the range...
_ Year of the Date Field
_ Month
_ Day of the Date Field
_ Isnull = True/False