Topic guide
Working with forms
In HTML, a form is a collection of elements inside <form>...</form> that allow a visitor to do things like enter text, select options, manipulate objects or controls, and so on, and then send that information back to the server.
4.2
5.0
5.1
5.2
6.0
Reference
Databases
Oracle notes
The Oracle backend stores TextFields as NCLOB columns. Oracle imposes some limitations on the usage of such LOB columns in general: LOB columns may not be used as primary keys. LOB columns may not be used in indexes.
4.2
5.0
5.1
Reference
Form fields
Built-in Field classes
classNullBooleanField(**kwargs)[source] : - Default widget: NullBooleanSelect - Empty value: None - Normalizes to: A Python True, False or None value. - Validates nothing (i.e., it never raises a ValidationError).
4.2
5.0
5.1
5.2
6.0
Reference
Query Expressions
Built-in Expressions
classRawSQL(sql,params,output_field=None)[source] Sometimes database expressions can’t easily express a complex WHERE clause. In these edge cases, use the RawSQL expression.
4.2
5.0
5.1
5.2
6.0
Reference
Model field reference
Field options
Field.choices[source] A mapping or iterable in the format described below to use as choices for this field.
4.2
5.0
5.1
5.2
6.0
How-to
How to write custom lookups
When using the above written abs lookup, the SQL produced will not use indexes efficiently in some cases. In particular, when we use change__abs__lt=27, this is equivalent to change__gt=-27 AND change__lt=27.
dev
Internals
Organization of the Django Project
The steering council selects Mergers as necessary to maintain their number at a minimum of three, in order to spread the workload and avoid over-burdening or burning out any individual Merger.
dev
Reference
GeoDjango Installation
The OSGeo4W installer helps to install the PROJ, GDAL, and GEOS libraries required by GeoDjango. First, download the OSGeo4W installer, and run it. Select Express Web-GIS Install and click next. In the ‘Select Packages’ list, ensure that GDAL is selected.
dev
Reference
GeoDjango Tutorial
When doing spatial queries, GeoDjango automatically transforms geometries if they’re in a different coordinate system.
dev
Reference
The messages framework
The messages framework can use different backends to store temporary messages. Django provides three built-in storage classes in django.contrib.messages: classstorage.session.SessionStorage : This class stores all messages inside of the request’s session. Therefore it requires Django’s contrib.sessions application.
dev
Reference
Databases
By default, the Oracle backend uses a RETURNING INTO clause to efficiently retrieve the value of an AutoField when inserting new rows.
dev
Reference
django-admin and manage.py
The colors used for syntax highlighting can be customized. Django ships with three color palettes: dark, suited to terminals that show white text on a black background. This is the default palette.
dev
Reference
Form fields
classNullBooleanField(**kwargs)[source] : - Default widget: NullBooleanSelect - Empty value: None - Normalizes to: A Python True, False or None value. - Validates nothing (i.e., it never raises a ValidationError).
dev
Reference
Form fields
Two fields are available for representing relationships between models: ModelChoiceField and ModelMultipleChoiceField. Both of these fields require a single queryset parameter that is used to create the choices for the field.
dev
Reference
Form fields
By default, ModelChoiceField and ModelMultipleChoiceField use ModelChoiceIterator to generate their field choices. When iterated, ModelChoiceIterator yields 2-tuple choices containing ModelChoiceIteratorValue instances as the first value element in each choice.
dev
Reference
Widgets
These widgets make use of the HTML elements <select>, <input type="checkbox">, and <input type="radio">. Widgets that render multiple choices have an option_template_name attribute that specifies the template used to render each choice.
dev
Reference
Query Expressions
Func() expressions are the base type of all expressions that involve database functions like COALESCE and LOWER, or aggregates like SUM.
dev
Reference
Query Expressions
classSubquery(queryset,output_field=None)[source] You can add an explicit subquery to a QuerySet using the Subquery expression.
dev
Reference
Query Expressions
classExists(queryset)[source] Exists is a Subquery subclass that uses an SQL EXISTS statement. In many cases it will perform better than a subquery since the database is able to stop evaluation of the subquery when a first matching row is found.
dev
Reference
Query Expressions
Subquery() that returns a boolean value and Exists() may be used as a condition in When expressions, or to directly filter a queryset: This will ensure that the subquery will not be added to the SELECT columns, which may result …
dev