1, middleware
Middleware generally do authentication or batch request processing, django in middleware, is actually a class, after the request and end, django middleware will be a corresponding method performed at the right time according to their own rules,
such as requests come perform process_request , view, process_response method
python face questions stronghold
2, Django, Tornado, Flask their strengths
Django: Django no socket, django aim is simple, rapid development, and follow the MVC design, multiple components can easily to "plug-in" as a service to the entire framework,
django there are many powerful third-party plug-ins. django has strong scalability.
Tornado: It is a non-blocking server, but also very fast, effective way to its non-blocking and the use of epoll, Future object Disadvantages: No session, need custom
Flask: it is a micro web framework, with the use SQLALchemy , jinja2 template, werkzeug interfaces
3, django version, Python version, linux version
django:1.11
Python:3.6
linux:6.9
4, template notes of what it was like django
Single line: {# #} Note
multiline comments: {% comment%}
5, django how to get concurrent
nginx + uwsig provide high concurrency django, nginx concurrent capacity of more than, a single concurrent capacity of over 10,000, in a purely static web service is highlighting its privileged place, because the underlying model using epoll asynchronous IO processing.
6, tornodo of ioloop know what that is?
Event Loop
7、select_related和prefetch_related,Q和F
select_related: many use, do not even take the initiative to query table
prefetch_related: one to many or many-time use, not even the table, do multiple queries
Q: used to construct a complex query
F: When updating to obtain the original value, specifically taking a column operated object
8. What is ORM?
ORM, ie Object-Relational Mapping (Object-relational mapping), its role is in between relational databases and business entities objects to do a mapping
ORM advantages and disadvantages:
Advantages: get rid of complex SQL operations to adapt to rapid development, so that the result becomes data to be simple, lower cost database migration
disadvantages: poor performance is not suitable for large applications, require complex SQL operations further achieved by SQL statements
9, CORS Cross-Origin Resource Sharing
Will first send a "pre-screening" opption ", request, if the" pre-screening "is successful, then send real data.
10, Django's Form has the following features?
Generate HTMl label to verify user data is_vaild, HTML Form submit preserves previous data submission, initial page display content
11, CBV and FBV
CBV class specified above plus or decorator added above method decorators @method_decorator, view and inheritance
12、cookie及session
cookie: the client is retained in the above set of key-value pairs cookie is not very safe, people can analyze stored in a local cookie
the session: the server is stored in the upper set of key-value pairs, depending on the cookie, cookie security index ratio high
13, django request lifecycle
First to uwsgi the request, the request to make a portion of the dispensing django frame, and then through all of the intermediate route, view, view process then returns to the intermediate member to return to uwsgi, return to the user.
14, uwsgi and wsgi
wsgi: a web server gateway interface is an interface between the framework and pyhton applications or web server, which is widely used django frame.
uwsgi: it is a web server, which implements the protocol wsgi role in HttpUwsgiModule Nginx is exchanged with the server Uwsgi
15, explain django - use the debug -toolbar
When using the django development site, you can use django-debug-toolbar for debugging, add 'debug-toolbar.midleware.Debug ToolbarMiddleware' in settings.py into MIDDLEWARE_CLASSES in the project.