DevHTTP

Django request variables, these lines assume you are inside a view according to:

def yourview(request, ...):

This page is based on the Request and response objects page in the Django 1 documentation.

HttpRequest attributes

request.path/request/django
request.methodGET
request.encodingNone

HttpRequest.META

A standard Python dictionary containing all available HTTP headers. Available headers depend on the client and server, but here are some examples:

request.META['DOCUMENT_ROOT'] % /var/www/empty
request.META['GATEWAY_INTERFACE'] % CGI/1.1
request.META['HTTP_ACCEPT'] % text/html,application/xhtml+xml,text/xml;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
request.META['HTTP_ACCEPT_CHARSET'] % ISO-8859-1,utf-8;q=0.7,*;q=0.7
request.META['HTTP_ACCEPT_ENCODING'] % gzip
request.META['HTTP_ACCEPT_LANGUAGE'] % en-us,en;q=0.5
request.META['HTTP_CACHE_CONTROL'] % no-cache
request.META['HTTP_CONNECTION'] % close
request.META['HTTP_HOST'] % devhttp.com
request.META['HTTP_PRAGMA'] % no-cache
request.META['HTTP_USER_AGENT'] % CCBot/1.0 (+http://www.commoncrawl.org/bot.html)
request.META['HTTP_X_CC_ID'] % ccc01-02
request.META['mod_wsgi.application_group'] % www.devhttp.com|
request.META['mod_wsgi.callable_object'] % application
request.META['mod_wsgi.listener_host'] % 
request.META['mod_wsgi.listener_port'] % 80
request.META['mod_wsgi.process_group'] % 
request.META['mod_wsgi.reload_mechanism'] % 0
request.META['mod_wsgi.script_reloading'] % 1
request.META['mod_wsgi.version'] % (2, 8)
request.META['PATH'] % /usr/local/bin:/usr/bin:/bin
request.META['PATH_INFO'] % /request/django
request.META['PATH_TRANSLATED'] % /var/www/vhost/devhttp.com/devhttp/django.wsgi/request/django
request.META['QUERY_STRING'] % 
request.META['REMOTE_ADDR'] % 38.107.179.211
request.META['REMOTE_PORT'] % 52284
request.META['REQUEST_METHOD'] % GET
request.META['REQUEST_URI'] % /request/django
request.META['SCRIPT_FILENAME'] % /var/www/vhost/devhttp.com/devhttp/django.wsgi
request.META['SCRIPT_NAME'] % 
request.META['SERVER_ADDR'] % 178.77.77.209
request.META['SERVER_ADMIN'] % [no address given]
request.META['SERVER_NAME'] % devhttp.com
request.META['SERVER_PORT'] % 80
request.META['SERVER_PROTOCOL'] % HTTP/1.1
request.META['SERVER_SIGNATURE'] % 
request.META['SERVER_SOFTWARE'] % Apache
request.META['wsgi.errors'] % <mod_wsgi.Log object at 0x2b7ba67f73c0>
request.META['wsgi.file_wrapper'] % <built-in method file_wrapper of mod_wsgi.Adapter object at 0x2b7ba653aa08>
request.META['wsgi.input'] % <mod_wsgi.Input object at 0x2b7ba6842d70>
request.META['wsgi.multiprocess'] % True
request.META['wsgi.multithread'] % False
request.META['wsgi.run_once'] % False
request.META['wsgi.url_scheme'] % http
request.META['wsgi.version'] % (1, 0)

request.user

This django.contrib.auth.models.User object is only interesting if you have authentication enabled. This site doesn't.

request.session

The session contains a key, randomly generated and repeated if the user is able to save the session information.

request.session['random'] = 526250636979

HttpRequest methods

request.get_host()devhttp.com
request.get_full_path()/request/django
request.build_absolute_uri()http://devhttp.com/request/django
request.is_secure()False
request.is_ajax()False

Copyright © Logfish.net
Exit →