admin.ModelAdmin.date_hierarchy

ModelAdmin.date_hierarchy Set date_hierarchy to the name of a DateField or DateTimeField in your model, and the change list page will include a date-based drilldown navigation by that field. Example: date_hierarchy = 'pub_date' This will intelligently populate itself based on available data, e.g. if all the dates are in one month, it’ll show the day-level drill-down only. Note date_hierarchy uses QuerySet.datetimes() internally. Please refer to its documentation for some caveats when time

contenttypes.models.ContentType

class ContentType Each instance of ContentType has two fields which, taken together, uniquely describe an installed model: app_label The name of the application the model is part of. This is taken from the app_label attribute of the model, and includes only the last part of the application’s Python import path; “django.contrib.contenttypes”, for example, becomes an app_label of “contenttypes”. model The name of the model class. Additionally, the following property is available:

http.HttpRequest.user

HttpRequest.user From the AuthenticationMiddleware: An instance of AUTH_USER_MODEL representing the currently logged-in user. If the user isn’t currently logged in, user will be set to an instance of AnonymousUser. You can tell them apart with is_authenticated, like so: if request.user.is_authenticated: ... # Do something for logged-in users. else: ... # Do something for anonymous users.

http.HttpRequest.resolver_match

HttpRequest.resolver_match An instance of ResolverMatch representing the resolved URL. This attribute is only set after URL resolving took place, which means it’s available in all views but not in middleware which are executed before URL resolving takes place (you can use it in process_view() though).

auth.get_user()

get_user(request) [source] Returns the user model instance associated with the given request’s session. It checks if the authentication backend stored in the session is present in AUTHENTICATION_BACKENDS. If so, it uses the backend’s get_user() method to retrieve the user model instance and then verifies the session by calling the user model’s get_session_auth_hash() method. Returns an instance of AnonymousUser if the authentication backend stored in the session is no longer in AUTHENTICATIO

db.models.prefetch_related_objects()

prefetch_related_objects(model_instances, *related_lookups) [source] New in Django 1.10. Prefetches the given lookups on an iterable of model instances. This is useful in code that receives a list of model instances as opposed to a QuerySet; for example, when fetching models from a cache or instantiating them manually. Pass an iterable of model instances (must all be of the same class) and the lookups or Prefetch objects you want to prefetch for. For example: >>> from django.db.mo

test.SimpleTestCase.assertFieldOutput()

SimpleTestCase.assertFieldOutput(fieldclass, valid, invalid, field_args=None, field_kwargs=None, empty_value='') [source] Asserts that a form field behaves correctly with various inputs. Parameters: fieldclass – the class of the field to be tested. valid – a dictionary mapping valid inputs to their expected cleaned values. invalid – a dictionary mapping invalid inputs to one or more raised error messages. field_args – the args passed to instantiate the field. field_kwargs – the kwargs

db.models.Field.get_db_prep_value()

get_db_prep_value(value, connection, prepared=False) [source] Converts value to a backend-specific value. By default it returns value if prepared=True and get_prep_value() if is False. See Converting query values to database values for usage. When loading data, from_db_value() is used:

GeoDjango Tutorial

Introduction GeoDjango is an included contrib module for Django that turns it into a world-class geographic Web framework. GeoDjango strives to make it as simple as possible to create geographic Web applications, like location-based services. Its features include: Django model fields for OGC geometries and raster data. Extensions to Django’s ORM for querying and manipulating spatial data. Loosely-coupled, high-level Python interfaces for GIS geometry and raster operations and data manipulation

auth.mixins.UserPassesTestMixin

class UserPassesTestMixin New in Django 1.9. When using class-based views, you can use the UserPassesTestMixin to do this. test_func() You have to override the test_func() method of the class to provide the test that is performed. Furthermore, you can set any of the parameters of AccessMixin to customize the handling of unauthorized users: from django.contrib.auth.mixins import UserPassesTestMixin class MyView(UserPassesTestMixin, View): def test_func(self): return self.re