URL distribution, isinstance, request. Get request querydict and UrlEncode, Post and get requests, limit_choices_to (model field)

Source: Internet
Author: User
Tags urlencode

This path is how to come, there is a URL to a route distributed over the

These two are equal, if the URL after the parentheses, then the front of the adorner is not used, and conversely, if the adorner, then the URL will not be appended with parentheses

Eg: other views.test this is a view function, and that URL () is a large list, which is full of URLs, which is called the two-level distribution URL,

After this, this is the return value of the function, which is a large ganso form, although there is no parenthesis, but there is a comma, here is a large ganso

Click Get_url again to jump here

This u front is a regular, which is the application name, which indicates that later model_config this is the URL of the style class, again, here is a big Ganso

Clicking this config will jump to this, and this model_config is a value belonging to the registry.

Click this registry jump to here, this is a dictionary

Class is instantiated,no parentheses are not the starting instance, and this should be the same as setting an alias; The addition of parentheses is to call the Init function without parentheses is to not call the Init function, instantiate parentheses, the automatic execution of the INIT function

Click Modelstark here to see the method below

—————————————————————————————————————————————————————————————————————

Isinstance

The isinstance function in Python, Isinstance is a built-in function in Python. Is the variable type used to determine an object.

Its first argument (object) is the second argument is the type name (int ...). Or a list of type names ((int,list,float) is a list). Its return value is Boolean (True or flase). Returns true if the type of the object is the same as the type of parameter two. If parameter two is a tuple, returns true if the object type is the same as one of the type names in the tuple. The simple thing is to determine if the object is the same type as the second parameter, for example: #-*-Coding:utf-8-*-p = ' 123 ' print "1.", Isinstance (p,str) #判断P是否是字符串类型a = "China" Print I Sinstance (A,unicode) #判断a是否是Unicode编码print isinstance (A, (UNICODE,STR)) #判断a所属类型是否包含在元组中list1 = [1,2,3,4,5]print Isinstance (list1,list) #判断list1是否是列表的类型
Reference: Https://www.cnblogs.com/beginner-boy/p/7240673.html

——————————————————————————————————————————————

Request. Querydict and UrlEncode of Get requests

Request. Get >>>>> get is a dictionary, but print out is <QueryDict:{}>, this dictionary type is immutable type, this type is not directly assigned to the operation, This querydict source code is written in the modified this, you can assign the operation, but it is best not to modify the source code; it is best not to modify the data, to modify, you can copy, and then in the copy of the operation

second point of knowledgeUrlEncode is the format of the circle, and only one quotation mark is needed.

A built-in method to get the form we want (eg:a=1&b=2)

This can be a dictionary of key-value pairs, assembled into a string (3.16 day 9.08 can be heard)

Summary, request. Get is an immutable dictionary that can be used to format this urlencode.

Third point of knowledge: Because it is an immutable type, to modify the dictionary, you need to set the parameters in parentheses =true

——————————————————————————————————————————————

Post and GET requests

The first is a GET request, the following is the GET request, then can fetch the URL on the key value pairs, with Post, it is an empty dictionary;Second, a POST request, you can also use get to remove the key value on the URL, The Post then takes out the key-value pairs in the label.

——————————————————————————————————————————————

Limit_choices_to "" "model field

In the model conversion process, the data can be filtered, according to the data conditions in the dictionary to filter, the filtered data into the SELECT tag

Limit_choice_to This is what, meaning is usually used ... all () is taken out of all the fields with this limit ..... After that, only the filtered fields are displayed, and the code in the middle of the two squares is the same as the code in the bottom box, which is a depart_id__in as a key, takes out the back 1002, 1003 as the value, and displays it in the background ps:depart_id__ In this is not a cross-table query, directly depart__ table name, this is a cross-table Ps:modelform, is to convert the model into a form of a to B, intermediary is the middle part modelform

——————————————————————————————————————————————

URL distribution, isinstance, request. Get request querydict and UrlEncode, Post and get requests, limit_choices_to (model field)

Related Article

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.