Before the operation the following data, we achieved to create a good data table, where the main demonstration of the following operations are no longer prepared to go into detail creation process
1. all (): Query all results
2. filter (** kwargs): contains the objects that match the given conditions
<3> get (** kwargs): returns the object with the given filter criteria matches one and only one result is returned, if the object matching the filter will throw more than one or no errors.
<4> exclude (** kwargs): it contains the object and filters that do not match the given conditions
<5> values (* field): Returns a ValueQuerySet-- QuerySet that a special, not obtained after running a series of instantiating an object model, but an iterative sequence dictionaries
<6> values_list (* field): it values () are very similar, it returns a tuple sequence, return values is a sequence of dictionary
<7> order_by (* field): sorting query results
order_by (* field): order query results ( '-id') / ( '. price')
# Print (models.Book.objects.order_by ( '. price')) The default is ascending #
# print (models.Book.objects .order_by ( '- price')) # minus sign is descending
<8> reverse (): Reverse order query results, note reverse () is usually called only on QuerySet having a defined sequence (designated Meta model in ordering or calling ORDER_BY class () method)
<9> distinct (): eliminate duplicate records (if you query across multiple tables, may be obtained from the returned results in the calculation of QuerySet reproducible results can now use distinct (), note that only supported by fields go in PostgreSQL. weight.)
<10> count (): returns the match query database (QuerySet that) the number of objects
<11> first (): returns the first record
<12> last (): returns the last record
<13> exists (): if QuerySet contains data, returns True, otherwise return False
13 will be operational summary
Return QuerySet object methods
all()
filter()
exclude()
order_by()
reverse()
distinct()
Special QuerySet
values () Returns an iterative sequence dictionaries
values_list () returns an ancestral sequence of iterations
Return specific object
get()
first()
last()
Returns a Boolean value methods are:
exists()
Returns the methods
count()