Django framework - The basic model system (ORM related operations)

Bound to the thirteen!

A method :( Memory Memory alphabetically)

 

<1> all (): Query all results

<2> count (): returns the match query database (QuerySet that) the number of objects.

<3> 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.)

<4> exclude (** kwargs) : it contains the given object does not match the filter criteria
<5> exists (): if QuerySet contains data, returns True, otherwise return False

<6> filter (** kwargs) : it contains the object and filters that match the given
<7> first (): returns the first record

<8> get (** kwargs): Returns the object with the given filter conditions that match, and only one result is returned, if the object matching the filter will throw more than one or no errors.

<9> last (): returns the last record

<10> order_by (* field): sorting query results

<11> reverse (): Reverse order query results, note reverse () only with defined generally on the order QuerySet that call (or call ordering specified ORDER_BY () method in class Meta model).

<12> values (* field) : Returns a special QuerySet that a ValueQuerySet--, obtained after running a series of not instantiate the object model, but a dictionary iterative sequence
<13> values_list (* field) : it is the values () are very similar, it returns a tuple sequence, return values is a sequence of dictionary

 

Memory Method Two :( classification memory)

Methods are returned QuerySet object (6)
All ()

filter()

exclude()

order_by()

reverse()

distinct()

Returns the specific object (3)
GET ()

first()

last()

Special QuerySet (2 th)
values () Returns an iterative sequence dictionaries

values_list () returns an ancestral sequence of iterations

Boolean value methods are (1)
EXISTS ()

Returns the methods (1)
COUNT ()

Guess you like

Origin www.cnblogs.com/mashangsir/p/11947483.html