Python Study notes Week 20th

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.