forms.ComboField

class ComboField(**kwargs) [source] Default widget: TextInput Empty value: '' (an empty string) Normalizes to: A Unicode object. Validates the given value against each of the fields specified as an argument to the ComboField. Error message keys: required, invalid Takes one extra required argument: fields The list of fields that should be used to validate the field’s value (in the order in which they are provided). >>> from django.forms import ComboField >>> f = Combo

views.static.serve()

static.serve(request, path, document_root, show_indexes=False) There may be files other than your project’s static assets that, for convenience, you’d like to have Django serve for you in local development. The serve() view can be used to serve any directory you give it. (This view is not hardened for production use and should be used only as a development aid; you should serve these files in production using a real front-end web server). The most likely example is user-uploaded content in M

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

utils.timezone.make_aware()

make_aware(value, timezone=None, is_dst=None) [source] Returns an aware datetime that represents the same point in time as value in timezone, value being a naive datetime. If timezone is set to None, it defaults to the current time zone. When pytz is installed, the exception pytz.AmbiguousTimeError will be raised if you try to make value aware during a DST transition where the same time occurs twice (when reverting from DST). Setting is_dst to True or False will avoid the exception by choosi

views.generic.base.ContextMixin.get_context_data()

get_context_data(**kwargs) Returns a dictionary representing the template context. The keyword arguments provided will make up the returned context. Example usage: def get_context_data(self, **kwargs): context = super(RandomNumberView, self).get_context_data(**kwargs) context['number'] = random.randrange(1, 100) return context The template context of all class-based generic views include a view variable that points to the View instance. Use alters_data where appropriate Note th

views.decorators.csrf.requires_csrf_token()

requires_csrf_token(view) Normally the csrf_token template tag will not work if CsrfViewMiddleware.process_view or an equivalent like csrf_protect has not run. The view decorator requires_csrf_token can be used to ensure the template tag does work. This decorator works similarly to csrf_protect, but never rejects an incoming request. Example: from django.views.decorators.csrf import requires_csrf_token from django.shortcuts import render @requires_csrf_token def my_view(request): c = {}

db.models.Field.from_db_value()

from_db_value(value, expression, connection, context) Converts a value as returned by the database to a Python object. It is the reverse of get_prep_value(). This method is not used for most built-in fields as the database backend already returns the correct Python type, or the backend itself does the conversion. See Converting values to Python objects for usage. Note For performance reasons, from_db_value is not implemented as a no-op on fields which do not require it (all Django fields).

gis.gdal.SpatialReference.identify_epsg()

identify_epsg() This method inspects the WKT of this SpatialReference and will add EPSG authority nodes where an EPSG identifier is applicable.

forms.Form.errors

Form.errors Access the errors attribute to get a dictionary of error messages: >>> f.errors {'sender': ['Enter a valid email address.'], 'subject': ['This field is required.']} In this dictionary, the keys are the field names, and the values are lists of Unicode strings representing the error messages. The error messages are stored in lists because a field can have multiple error messages. You can access errors without having to call is_valid() first. The form’s data will be valida

db.models.Options.order_with_respect_to

Options.order_with_respect_to Makes this object orderable with respect to the given field, usually a ForeignKey. This can be used to make related objects orderable with respect to a parent object. For example, if an Answer relates to a Question object, and a question has more than one answer, and the order of answers matters, you’d do this: from django.db import models class Question(models.Model): text = models.TextField() # ... class Answer(models.Model): question = models.Fo