djangodocs.org

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

FormView

Reference Generic editing views

classdjango.views.generic.edit.FormView : A view that displays a form. On error, redisplays the form with validation errors; on success, redirects to a new URL. classdjango.views.generic.edit.BaseFormView : A base view for displaying a form.

4.2 5.0 5.1 5.2 6.0

Tags

Topic guide Templates The Django template languageSyntax

Tags provide arbitrary logic in the rendering process. This definition is deliberately vague. For example, a tag can output content, serve as a control structure e.g.

4.2 5.0 5.1 5.2 6.0

Usage

Topic guide Templates Support for template engines

Template objects returned by get_template() and select_template() must provide a render() method with the following signature: Template.render(context=None,request=None) : Renders this template with a given context. Here’s an example of the search algorithm.

4.2 5.0 5.1 5.2 6.0

Middleware ordering

Reference Middleware

After UpdateCacheMiddleware: Modifies Vary header. 4. SessionMiddleware Before any middleware that may raise an exception to trigger an error view (such as PermissionDenied) if you’re using CSRF_USE_SESSIONS. After UpdateCacheMiddleware: Modifies Vary header. 5.

dev

Middleware ordering

Reference Middleware

After UpdateCacheMiddleware: Modifies Vary header. 4. SessionMiddleware Before any middleware that may raise an exception to trigger an error view (such as PermissionDenied) if you’re using CSRF_USE_SESSIONS. After UpdateCacheMiddleware: Modifies Vary header. 5.

4.2 5.0 5.1 5.2 6.0

T

Index

… - wordwrap - yesno - template tag - autoescape - block - blocktrans - blocktranslate - cache - comment - csrf_token - cycle - debug - extends - filter - firstof - for - get_available_languages - get_current_language - get_current_language_bidi - …

CreateView

Reference Generic editing views

classdjango.views.generic.edit.CreateView : A view that displays a form for creating an object, redisplaying the form with validation errors (if there are any) and saving the object. classdjango.views.generic.edit.BaseCreateView : A base view for creating a new object instance.

dev

UpdateView

Reference Generic editing views

classdjango.views.generic.edit.UpdateView : A view that displays a form for editing an existing object, redisplaying the form with validation errors (if there are any) and saving changes to the object.

dev

DeleteView

Reference Generic editing views

classdjango.views.generic.edit.DeleteView : A view that displays a confirmation page and deletes an existing object. The given object will only be deleted if the request method is POST.

dev

Topic guide Time zones

The current time zone is the equivalent of the current locale for translations. However, there’s no equivalent of the Accept-Language HTTP header that Django could use to determine the user’s time zone automatically. Instead, Django provides time zone selection functions.

dev

Topic guide Translation

set_language(request)[source] As a convenience, Django comes with a view, django.views.i18n.set_language(), that sets a user’s language preference and redirects to a given URL or, by default, back to the previous page.

dev

Built-in backends

Topic guide Templates

when using render()), the Jinja2 backend adds the globals request, csrf_input, and csrf_token to the context. Apart from that, this backend doesn’t create a Django-flavored environment. It doesn’t know about Django filters and tags.

dev

CreateView

Reference Generic editing views

classdjango.views.generic.edit.CreateView : A view that displays a form for creating an object, redisplaying the form with validation errors (if there are any) and saving the object. classdjango.views.generic.edit.BaseCreateView : A base view for creating a new object instance.

4.2 5.0 5.1 5.2 6.0

UpdateView

Reference Generic editing views

classdjango.views.generic.edit.UpdateView : A view that displays a form for editing an existing object, redisplaying the form with validation errors (if there are any) and saving changes to the object.

4.2 5.0 5.1 5.2 6.0

DeleteView

Reference Generic editing views

classdjango.views.generic.edit.DeleteView : A view that displays a confirmation page and deletes an existing object. The given object will only be deleted if the request method is POST.

4.2 5.0 5.1 5.2 6.0

Topic guide Time zones Concepts

The current time zone is the equivalent of the current locale for translations. However, there’s no equivalent of the Accept-Language HTTP header that Django could use to determine the user’s time zone automatically. Instead, Django provides time zone selection functions.

4.2 5.0 5.1 5.2 6.0

Topic guide Translation Miscellaneous

set_language(request)[source] As a convenience, Django comes with a view, django.views.i18n.set_language(), that sets a user’s language preference and redirects to a given URL or, by default, back to the previous page.

4.2 5.0 5.1 5.2 6.0