djangodocs.org

1305 sections across all versions Narrow to Django 6.0 (current) →

1.5

Internals Django Deprecation Timeline

The undocumented function django.contrib.formtools.utils.security_hash will be removed, instead use django.contrib.formtools.utils.form_hmac The function-based generic view modules will be removed in favor of their class-based equivalents, outlined here. The django.core.servers.basehttp.AdminMediaHandler will be removed. In its place use django.contrib.staticfiles.handlers.StaticFilesHandler.

dev

Internals Django’s security policy

… sanitized: Developers must always validate and sanitize input before using it. The correct approach would be to use a Django form to ensure email is properly validated: Similarly, as Django’s raw SQL constructs (such as extra(), RawSQL, and keyword arguments …

dev

Overview

Tutorial Writing your first Django app, part 3

Question “detail” page – displays a question text, with no results but with a form to vote. Question “results” page – displays results for a particular question. Vote action – handles voting for a particular choice in a particular question.

dev

Adding related objects

Tutorial Writing your first Django app, part 7

The “Add choice” form looks like this: In that form, the “Question” field is a select box containing every question in the database. Django knows that a ForeignKey should be represented in the admin as a <select> box.

dev

Application registry

Reference Applications

app_name is the full name of the app, e.g. 'django.contrib.admin'. apps.get_model(app_label,model_name,require_ready=True) : 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.

dev

CreateView

Reference Class-based generic views - flattened index

classCreateView Attributes (with optional accessor): content_type context_object_name [get_context_object_name()] extra_context fields form_class [get_form_class()] http_method_names initial [get_initial()] model pk_url_kwarg prefix [get_prefix()] query_pk_and_slug queryset [get_queryset()] response_class [render_to_response()] slug_field [get_slug_field()] slug_url_kwarg success_url [get_success_url()] template_engine template_name [get_template_names()] template_name_field template_name_suffix Methods as_view() dispatch() form_invalid() form_valid() get() …

dev

UpdateView

Reference Class-based generic views - flattened index

classUpdateView Attributes (with optional accessor): content_type context_object_name [get_context_object_name()] extra_context fields form_class [get_form_class()] http_method_names initial [get_initial()] model pk_url_kwarg prefix [get_prefix()] query_pk_and_slug queryset [get_queryset()] response_class [render_to_response()] slug_field [get_slug_field()] slug_url_kwarg success_url [get_success_url()] template_engine template_name [get_template_names()] template_name_field template_name_suffix Methods as_view() dispatch() form_invalid() form_valid() get() …

dev

Generic editing views

Reference

The following views are described on this page and provide a foundation for editing content: django.views.generic.edit.FormView django.views.generic.edit.CreateView django.views.generic.edit.UpdateView django.views.generic.edit.DeleteView NOTE: The messages framework contains > SuccessMessageMixin, which > facilitates presenting messages about successful form submissions.

dev

DeleteView

Reference Generic editing views

If this view is fetched via GET, it will display a confirmation page that should contain a form that POSTs to the same URL. classdjango.views.generic.edit.BaseDeleteView : A base view for deleting an object instance.

dev

ProcessFormView

Reference Editing mixins

classdjango.views.generic.edit.ProcessFormView : A mixin that provides basic HTTP GET and POST workflow.

dev

Reference Admin actions

For example, to make an action available only on the change form, set location to ActionLocation.CHANGE_FORM: To make an action available on both the change list and the change form: Notice that description and description_plural were provided.

dev

Reference The Django admin site

This can be accomplished by using a Media inner class on your ModelAdmin: The staticfiles app prepends STATIC_URL (or MEDIA_URL if STATIC_URL is None) to any asset paths. The same rules apply as regular asset definitions on forms.

dev

jQuery

Reference The Django admin site

Also, your own admin forms or widgets depending on django.jQuery must specify js=['admin/js/jquery.init.js', …] when declaring form media assets.

dev

Raster Lookups

Reference GeoDjango Database API

… right hand side, a tuple of the raster and band index can be specified. This results in the following general form for lookups involving rasters (assuming the Elevation model used in the GeoDjango Model API): For example: On the left …

dev

Widget attributes

Reference GeoDjango Forms API

BaseGeometryWidget.geom_type : The OpenGIS geometry type, generally set by the form field. BaseGeometryWidget.map_srid : SRID code used by the map (default is 4326).

dev

Widget classes

Reference GeoDjango Forms API

OpenLayersWidget classOpenLayersWidget[source] : This is the default widget used by all GeoDjango form fields. Attributes are: OSMWidget classOSMWidget[source] : This widget specialized OpenLayersWidget and uses an OpenStreetMap base layer to display geographic objects on. Attributes are:

dev