db.models.query.QuerySet.exists()

exists() Returns True if the QuerySet contains any results, and False if not. This tries to perform the query in the simplest and fastest way possible, but it does execute nearly the same query as a normal QuerySet query. exists() is useful for searches relating to both object membership in a QuerySet and to the existence of any objects in a QuerySet, particularly in the context of a large QuerySet. The most efficient method of finding whether a model with a unique field (e.g. primary_key) i

Form and field validation

Form validation happens when the data is cleaned. If you want to customize this process, there are various places to make changes, each one serving a different purpose. Three types of cleaning methods are run during form processing. These are normally executed when you call the is_valid() method on a form. There are other things that can also trigger cleaning and validation (accessing the errors attribute or calling full_clean() directly), but normally they won’t be needed. In general, any clea

test.Response.request

request The request data that stimulated the response.

apps.apps.get_model()

apps.get_model(app_label, model_name) Returns the Model with the given app_label and model_name. As a shortcut, this method also accepts a single argument in the form app_label.model_name. model_name is case-insensitive. Raises LookupError if no such application or model exists. Raises ValueError when called with a single argument that doesn’t contain exactly one dot.

utils.encoding.force_bytes()

force_bytes(s, encoding='utf-8', strings_only=False, errors='strict') [source] Similar to smart_bytes, except that lazy instances are resolved to bytestrings, rather than kept as lazy objects. If strings_only is True, don’t convert (some) non-string-like objects.

gis.db.models.functions.Union

class Union(expr1, expr2, **extra) Availability: MySQL (≥ 5.6.1), PostGIS, Oracle, SpatiaLite Accepts two geographic fields or expressions and returns the union of both geometries.

core.paginator.Page.number

Page.number The 1-based page number for this page.

core.management.BaseCommand.style

BaseCommand.style An instance attribute that helps create colored output when writing to stdout or stderr. For example: self.stdout.write(self.style.SUCCESS('...')) See Syntax coloring to learn how to modify the color palette and to see the available styles (use uppercased versions of the “roles” described in that section). If you pass the --no-color option when running your command, all self.style() calls will return the original string uncolored.

Form handling with class-based views

Form processing generally has 3 paths: Initial GET (blank or prepopulated form) POST with invalid data (typically redisplay form with errors) POST with valid data (process the data and typically redirect) Implementing this yourself often results in a lot of repeated boilerplate code (see Using a form in a view). To help avoid this, Django provides a collection of generic class-based views for form processing. Basic forms Given a simple contact form: from django import forms class ContactForm

gis.feeds.W3CGeoFeed

class W3CGeoFeed [source] Note W3C Geo formatted feeds only support PointField geometries.