db.models.functions.datetime.Trunc

class Trunc(expression, kind, output_field=None, tzinfo=None, **extra) [source] Truncates a date up to a significant component. When you only care if something happened in a particular year, hour, or day, but not the exact second, then Trunc (and its subclasses) can be useful to filter or aggregate your data. For example, you can use Trunc to calculate the number of sales per day. Trunc takes a single expression, representing a DateField or DateTimeField, a kind representing a date part, and

Database access optimization

Django’s database layer provides various ways to help developers get the most out of their databases. This document gathers together links to the relevant documentation, and adds various tips, organized under a number of headings that outline the steps to take when attempting to optimize your database usage. Profile first As general programming practice, this goes without saying. Find out what queries you are doing and what they are costing you. You may also want to use an external project like

django.contrib.humanize

A set of Django template filters useful for adding a “human touch” to data. To activate these filters, add 'django.contrib.humanize' to your INSTALLED_APPS setting. Once you’ve done that, use {% load humanize %} in a template, and you’ll have access to the following filters. apnumber For numbers 1-9, returns the number spelled out. Otherwise, returns the number. This follows Associated Press style. Examples: 1 becomes one. 2 becomes two. 10 becomes 10. You can pass in either an integer or

core.files.storage.Storage.save()

save(name, content, max_length=None) [source] Saves a new file using the storage system, preferably with the name specified. If there already exists a file with this name name, the storage system may modify the filename as necessary to get a unique name. The actual name of the stored file will be returned. The max_length argument is passed along to get_available_name(). The content argument must be an instance of django.core.files.File or a file-like object that can be wrapped in File.

http.QueryDict.get()

QueryDict.get(key, default=None) Uses the same logic as __getitem__() above, with a hook for returning a default value if the key doesn’t exist.

http.HttpResponsePermanentRedirect

class HttpResponsePermanentRedirect [source] Like HttpResponseRedirect, but it returns a permanent redirect (HTTP status code 301) instead of a “found” redirect (status code 302).

utils.translation.to_locale()

to_locale(language) [source] Turns a language name (en-us) into a locale name (en_US).

postgres.forms.DateRangeField

class DateRangeField [source] Based on DateField and translates its input into DateRange. Default for DateRangeField.

gis.gdal.GDALBand.std

std New in Django 1.10. The standard deviation of all pixel values of the band (excluding the “no data” value).

urls.ResolverMatch.namespace

namespace The instance namespace for the URL pattern that matches the URL.