db.models.FilePathField.path

FilePathField.path Required. The absolute filesystem path to a directory from which this FilePathField should get its choices. Example: "/home/images".

Installing PostGIS

PostGIS adds geographic object support to PostgreSQL, turning it into a spatial database. GEOS, PROJ.4 and GDAL should be installed prior to building PostGIS. You might also need additional libraries, see PostGIS requirements. The psycopg2 module is required for use as the database adapter when using GeoDjango with PostGIS. On Debian/Ubuntu, you are advised to install the following packages: postgresql-x.x, postgresql-x.x-postgis, postgresql-server-dev-x.x, python-psycopg2 (x.x matching the Pos

db.models.Field.unique_for_date

Field.unique_for_date Set this to the name of a DateField or DateTimeField to require that this field be unique for the value of the date field. For example, if you have a field title that has unique_for_date="pub_date", then Django wouldn’t allow the entry of two records with the same title and pub_date. Note that if you set this to point to a DateTimeField, only the date portion of the field will be considered. Besides, when USE_TZ is True, the check will be performed in the current time z

template.response.SimpleTemplateResponse.resolve_template()

SimpleTemplateResponse.resolve_template(template) [source] Resolves the template instance to use for rendering. Accepts a backend-dependent template object (such as those returned by get_template()), the name of a template, or a list of template names. Returns the backend-dependent template object instance to be rendered. Override this method in order to customize template loading.

GeoDjango Database API

Spatial Backends GeoDjango currently provides the following spatial database backends: django.contrib.gis.db.backends.postgis django.contrib.gis.db.backends.mysql django.contrib.gis.db.backends.oracle django.contrib.gis.db.backends.spatialite MySQL Spatial Limitations MySQL’s spatial extensions only support bounding box operations (what MySQL calls minimum bounding rectangles, or MBR). Specifically, MySQL does not conform to the OGC standard: Currently, MySQL does not implement these functi

db.transaction.on_commit()

on_commit(func, using=None) [source] Pass any function (that takes no arguments) to on_commit(): from django.db import transaction def do_something(): pass # send a mail, invalidate a cache, fire off a Celery task, etc. transaction.on_commit(do_something) You can also wrap your function in a lambda: transaction.on_commit(lambda: some_celery_task.delay('arg1')) The function you pass in will be called immediately after a hypothetical database write made where on_commit() is called wou

admin.ModelAdmin.exclude

ModelAdmin.exclude This attribute, if given, should be a list of field names to exclude from the form. For example, let’s consider the following model: from django.db import models class Author(models.Model): name = models.CharField(max_length=100) title = models.CharField(max_length=3) birth_date = models.DateField(blank=True, null=True) If you want a form for the Author model that includes only the name and title fields, you would specify fields or exclude like this: from dja

forms.MultipleHiddenInput

class MultipleHiddenInput [source] Multiple <input type='hidden' ...> widgets. A widget that handles multiple hidden widgets for fields that have a list of values. choices This attribute is optional when the form field does not have a choices attribute. If it does, it will override anything you set here when the attribute is updated on the Field.

db.models.query.QuerySet.count()

count() Returns an integer representing the number of objects in the database matching the QuerySet. The count() method never raises exceptions. Example: # Returns the total number of entries in the database. Entry.objects.count() # Returns the number of entries whose headline contains 'Lennon' Entry.objects.filter(headline__contains='Lennon').count() A count() call performs a SELECT COUNT(*) behind the scenes, so you should always use count() rather than loading all of the record into Pyt

db.models.Transform.lhs

lhs The left-hand side - what is being transformed. It must follow the Query Expression API.