-
Notifications
You must be signed in to change notification settings - Fork 7
Django context
In most cases, the client is a browser, but it can also be a mobile device or another application consuming your APIs. The client submits an HTTP request message to your server and in turn receives an HTTP response message. The response contains completion status information about the request and may contain any content requested by the client in its message body.
The Proxy/Static HTTP Server, like nginx and Cherokee, gets the HTTP request and returns static content or routes the request for dynamic content to the appropriate Application HTTP Server.
An application HTTP server, like Apache, Gunicorn and Lighttpd, receives the HTTP request and efficiently interfaces with your Django application.
The URL dispatcher receives the incoming HTTP request and, given the URL of the request and a URL configuration (URLconf) stored in urls.py, uses regular expressions to match a URL to the correct view.
The Django middleware is an optional set of Python classes that conduct pre-processing tasks like create the request.session and request.user for your view, short-circuit the call to your view function if the response for that view has already been cached, or log information about the request for debug purposes.
A view is a Python function that allows you to process the incoming HTTP request and return a response. The convention is to put views in a file called views.py, placed in your project or application directory.
A model is a Python class that represents your data; a blueprint of your data. It contains the essential fields and behaviors of the data you’re storing. Generally, each model maps to a single database table and each attribute of the model represents a database field. Once you’ve created your data models, Django automatically gives you a database-abstraction API that lets you create, retrieve, update and delete objects.
A QuerySet is a collection of your instantiated model objects. To retrieve data from your database, you construct a QuerySet via a Manager on your model class. In SQL terms, a QuerySet equates to a SELECT statement, and a QuerySet filter is a limiting clause such as WHERE or LIMIT.
Django officially supports PostgreSQL, MySQL, Oracle and SQLite. There are backends provided by 3rd parties that allow you to use additional databases with Django: Sybase SQL Anywhere, IBM DB2, Microsoft SQL Server 2005, Firebird and ODBC.