http.HttpRequest.build_absolute_uri()

HttpRequest.build_absolute_uri(location) [source] Returns the absolute URI form of location. If no location is provided, the location will be set to request.get_full_path(). If the location is already an absolute URI, it will not be altered. Otherwise the absolute URI is built using the server variables available in this request. Example: "https://example.com/music/bands/the_beatles/?print=true" Note Mixing HTTP and HTTPS on the same site is discouraged, therefore build_absolute_uri() will

http.Http404

class django.http.Http404 When you return an error such as HttpResponseNotFound, you’re responsible for defining the HTML of the resulting error page: return HttpResponseNotFound('<h1>Page not found</h1>') For convenience, and because it’s a good idea to have a consistent 404 error page across your site, Django provides an Http404 exception. If you raise Http404 at any point in a view function, Django will catch it and return the standard error page for your application, along w

http.HttpRequest.body

HttpRequest.body The raw HTTP request body as a byte string. This is useful for processing data in different ways than conventional HTML forms: binary images, XML payload etc. For processing conventional form data, use HttpRequest.POST. You can also read from an HttpRequest using a file-like interface. See HttpRequest.read().

http.HttpRequest

class HttpRequest [source]

http.HttpRequest.content_params

HttpRequest.content_params New in Django 1.10. A dictionary of key/value parameters included in the CONTENT_TYPE header.

http.FileResponse

class FileResponse [source] FileResponse is a subclass of StreamingHttpResponse optimized for binary files. It uses wsgi.file_wrapper if provided by the wsgi server, otherwise it streams the file out in small chunks. FileResponse expects a file open in binary mode like so: >>> from django.http import FileResponse >>> response = FileResponse(open('myfile.png', 'rb'))

How to use Django with uWSGI

uWSGI is a fast, self-healing and developer/sysadmin-friendly application container server coded in pure C. See also The uWSGI docs offer a tutorial covering Django, nginx, and uWSGI (one possible deployment setup of many). The docs below are focused on how to integrate Django with uWSGI. Prerequisite: uWSGI The uWSGI wiki describes several installation procedures. Using pip, the Python package manager, you can install any uWSGI version with a single command. For example: # Install current st

How to use Django with Apache and mod_wsgi

Deploying Django with Apache and mod_wsgi is a tried and tested way to get Django into production. mod_wsgi is an Apache module which can host any Python WSGI application, including Django. Django will work with any version of Apache which supports mod_wsgi. The official mod_wsgi documentation is fantastic; it’s your source for all the details about how to use mod_wsgi. You’ll probably want to start with the installation and configuration documentation. Basic configuration Once you’ve got mod_w

How to use Django with Gunicorn

Gunicorn (‘Green Unicorn’) is a pure-Python WSGI server for UNIX. It has no dependencies and is easy to install and use. Installing Gunicorn Installing gunicorn is as easy as pip install gunicorn. For more details, see the gunicorn documentation. Running Django in Gunicorn as a generic WSGI application When Gunicorn is installed, a gunicorn command is available which starts the Gunicorn server process. At its simplest, gunicorn just needs to be called with the location of a module containing a

How to install Django

This document will get you up and running with Django. Install Python Being a Python Web framework, Django requires Python. See What Python version can I use with Django? for details. Get the latest version of Python at https://www.python.org/download/ or with your operating system’s package manager. Django on Jython If you use Jython (a Python implementation for the Java platform), you’ll need to follow a few additional steps. See Running Django on Jython for details. Python on Windows If y