redirects.middleware.RedirectFallbackMiddleware.response_redirect_class

response_redirect_class The HttpResponse class that handles the redirect. Defaults to HttpResponsePermanentRedirect.

redirects.middleware.RedirectFallbackMiddleware.response_gone_class

response_gone_class The HttpResponse class used when a Redirect is not found for the requested path or has a blank new_path value. Defaults to HttpResponseGone.

redirects.middleware.RedirectFallbackMiddleware

class middleware.RedirectFallbackMiddleware You can change the HttpResponse classes used by the middleware by creating a subclass of RedirectFallbackMiddleware and overriding response_gone_class and/or response_redirect_class. response_gone_class The HttpResponse class used when a Redirect is not found for the requested path or has a blank new_path value. Defaults to HttpResponseGone. response_redirect_class The HttpResponse class that handles the redirect. Defaults to HttpResponseP

Quick install guide

Before you can use Django, you’ll need to get it installed. We have a complete installation guide that covers all the possibilities; this guide will guide you to a simple, minimal installation that’ll work while you walk through the introduction. Install Python Being a Python Web framework, Django requires Python. See What Python version can I use with Django? for details. Python includes a lightweight database called SQLite so you won’t need to set up a database just yet. Get the latest versio

Providing initial data for models

It’s sometimes useful to pre-populate your database with hard-coded data when you’re first setting up an app. You can provide initial data via fixtures. Providing initial data with fixtures A fixture is a collection of data that Django knows how to import into a database. The most straightforward way of creating a fixture if you’ve already got some data is to use the manage.py dumpdata command. Or, you can write fixtures by hand; fixtures can be written as JSON, XML or YAML (with PyYAML install

PostgreSQL specific lookups

Trigram similarity New in Django 1.10. The trigram_similar lookup allows you to perform trigram lookups, measuring the number of trigrams (three consecutive characters) shared, using a dedicated PostgreSQL extension. A trigram lookup is given an expression and returns results that have a similarity measurement greater than the current similarity threshold. To use it, add 'django.contrib.postgres' in your INSTALLED_APPS and activate the pg_trgm extension on PostgreSQL. You can install the exte

postgres.validators.RangeMinValueValidator

class RangeMinValueValidator(limit_value, message=None) [source] Validates that the lower bound of the range is not less than the limit_value.

postgres.validators.RangeMaxValueValidator

class RangeMaxValueValidator(limit_value, message=None) [source] Validates that the upper bound of the range is not greater than limit_value.

postgres.validators.KeysValidator

class KeysValidator(keys, strict=False, messages=None) [source] Validates that the given keys are contained in the value. If strict is True, then it also checks that there are no other keys present. The messages passed should be a dict containing the keys missing_keys and/or extra_keys. Note Note that this checks only for the existence of a given key, not that the value of a key is non-empty.

postgres.search.TrigramSimilarity

class TrigramSimilarity(expression, string, **extra) [source] New in Django 1.10. Accepts a field name or expression, and a string or expression. Returns the trigram similarity between the two arguments. Usage example: >>> from django.contrib.postgres.search import TrigramSimilarity >>> Author.objects.create(name='Katy Stevens') >>> Author.objects.create(name='Stephen Keats') >>> test = 'Katie Stephens' >>> Author.objects.annotate( ... simil