Directory:
First, ORM
1. Supplementary Enquiry
Content:
First, ORM
1, Query Supplement:
1, models. USR.objects.all (). VALUES (' id ', ' name ')
This statement is equivalent to the Select Id,name from USER in the SQL statement, which means that the values of a few columns can be taken separately, and the obtained value is still queryset, but the inner element becomes a dictionary
2, models. USR.objects.all (). Value_list (' id ', ' name ')
Represents a value that can be taken separately from a few columns, and the obtained value is still queryset, but the inner element becomes a tuple
3, models. USR.objects.filter (id=1). First ()
Represents a single object, if the fetch is not returned to none
4, models. USR.objects.filter (nid__gt=0). VALUES (' nid ', ' hostname ', ' b_id ', ' b__caption ')
Here are two points to note:
1. Nid is followed by a __gt with two underscores, also less than, greater than or equal to less than or equal to (__lt __gte __lte) These are double underlines
2, in the values of the need to cross-table value, the same need double underline, such as b__caption, but b_id is a single underline, because it is only in the user table does not have a cross-table value, where the common cross-table value of "." is not valid, you must use "__"
Python Study notes Week 20th