auth.middleware.PersistentRemoteUserMiddleware

class PersistentRemoteUserMiddleware New in Django 1.9. Middleware for utilizing Web server provided authentication when enabled only on the login page. See Using REMOTE_USER on login pages only for usage details.

Django Exceptions

Django raises some of its own exceptions as well as standard Python exceptions. Django Core Exceptions Django core exception classes are defined in django.core.exceptions. AppRegistryNotReady exception AppRegistryNotReady [source] This exception is raised when attempting to use models before the app loading process, which initializes the ORM, is complete. ObjectDoesNotExist exception ObjectDoesNotExist [source] The base class for DoesNotExist exceptions; a try/except for ObjectDoesNotE

Writing and running tests

See also The testing tutorial, the testing tools reference, and the advanced testing topics. This document is split into two primary sections. First, we explain how to write tests with Django. Then, we explain how to run them. Writing tests Django’s unit tests use a Python standard library module: unittest. This module defines tests using a class-based approach. Here is an example which subclasses from django.test.TestCase, which is a subclass of unittest.TestCase that runs each test inside a

views.generic.dates.BaseDateListView.get_dated_items()

get_dated_items() [source] Returns a 3-tuple containing (date_list, object_list, extra_context). date_list is the list of dates for which data is available. object_list is the list of objects. extra_context is a dictionary of context data that will be added to any context data provided by the MultipleObjectMixin.

db.models.ImageField.height_field

ImageField.height_field Name of a model field which will be auto-populated with the height of the image each time the model instance is saved.

db.models.fields.related.RelatedManager.clear()

clear() Removes all objects from the related object set: >>> b = Blog.objects.get(id=1) >>> b.entry_set.clear() Note this doesn’t delete the related objects – it just disassociates them. Just like remove(), clear() is only available on ForeignKeys where null=True and it also accepts the bulk keyword argument.

forms.Field.localize

Field.localize The localize argument enables the localization of form data input, as well as the rendered output. See the format localization documentation for more information.

views.generic.list.MultipleObjectMixin.paginator_class

paginator_class The paginator class to be used for pagination. By default, django.core.paginator.Paginator is used. If the custom paginator class doesn’t have the same constructor interface as django.core.paginator.Paginator, you will also need to provide an implementation for get_paginator().

views.generic.edit.CreateView.template_name_suffix

template_name_suffix The CreateView page displayed to a GET request uses a template_name_suffix of '_form'. For example, changing this attribute to '_create_form' for a view creating objects for the example Author model would cause the default template_name to be 'myapp/author_create_form.html'.

db.models.Variance.sample

sample By default, Variance returns the population variance. However, if sample=True, the return value will be the sample variance. SQLite SQLite doesn’t provide Variance out of the box. An implementation is available as an extension module for SQLite. Consult the SQlite documentation for instructions on obtaining and installing this extension.