test.Client.login()

login(**credentials) [source] If your site uses Django’s authentication system and you deal with logging in users, you can use the test client’s login() method to simulate the effect of a user logging into the site. After you call this method, the test client will have all the cookies and session data required to pass any login-based tests that may form part of a view. The format of the credentials argument depends on which authentication backend you’re using (which is configured by your AUT

test.Client.delete()

delete(path, data='', content_type='application/octet-stream', follow=False, secure=False, **extra) [source] Makes a DELETE request on the provided path and returns a Response object. Useful for testing RESTful interfaces. When data is provided, it is used as the request body, and a Content-Type header is set to content_type. The follow, secure and extra arguments act the same as for Client.get().

test.Client.force_login()

force_login(user, backend=None) [source] New in Django 1.9. If your site uses Django’s authentication system, you can use the force_login() method to simulate the effect of a user logging into the site. Use this method instead of login() when a test requires a user be logged in and the details of how a user logged in aren’t important. Unlike login(), this method skips the authentication and verification steps: inactive users (is_active=False) are permitted to login and the user’s credentia

test.Client.get()

get(path, data=None, follow=False, secure=False, **extra) [source] Makes a GET request on the provided path and returns a Response object, which is documented below. The key-value pairs in the data dictionary are used to create a GET data payload. For example: >>> c = Client() >>> c.get('/customers/details/', {'name': 'fred', 'age': 7}) ...will result in the evaluation of a GET request equivalent to: /customers/details/?name=fred&age=7 The extra keyword arguments para

test.Client.cookies

Client.cookies A Python SimpleCookie object, containing the current values of all the client cookies. See the documentation of the http.cookies module for more.

test.Client

class Client(enforce_csrf_checks=False, **defaults) [source] It requires no arguments at time of construction. However, you can use keywords arguments to specify some default headers. For example, this will send a User-Agent HTTP header in each request: >>> c = Client(HTTP_USER_AGENT='Mozilla/5.0') The values from the extra keywords arguments passed to get(), post(), etc. have precedence over the defaults passed to the class constructor. The enforce_csrf_checks argument can be used

Templates

Django’s template engine provides a powerful mini-language for defining the user-facing layer of your application, encouraging a clean separation of application and presentation logic. Templates can be maintained by anyone with an understanding of HTML; no knowledge of Python is required. For introductory material, see Templates topic guide. The Django template languageTemplates Variables Filters Tags Comments Template inheritance Automatic HTML escaping Accessing method calls Custom tag and f

template.Template.render()

Template.render(context) [source] Call the Template object’s render() method with a Context to “fill” the template: >>> from django.template import Context, Template >>> template = Template("My name is {{ my_name }}.") >>> context = Context({"my_name": "Adrian"}) >>> template.render(context) "My name is Adrian." >>> context = Context({"my_name": "Dolores"}) >>> template.render(context) "My name is Dolores."

template.response.SimpleTemplateResponse.__init__()

SimpleTemplateResponse.__init__(template, context=None, content_type=None, status=None, charset=None, using=None) [source] Instantiates a SimpleTemplateResponse object with the given template, context, content type, HTTP status, and charset. template A backend-dependent template object (such as those returned by get_template()), the name of a template, or a list of template names. context A dict of values to add to the template context. By default, this is an empty dictionary. content_t

template.Template

class Template [source] This class lives at django.template.Template. The constructor takes one argument — the raw template code: from django.template import Template template = Template("My name is {{ my_name }}.") Behind the scenes The system only parses your raw template code once – when you create the Template object. From then on, it’s stored internally as a tree structure for performance. Even the parsing itself is quite fast. Most of the parsing happens via a single call to a singl