djangodocs.org

663 sections in Django 5.0 Search all versions →

TimeField

Reference Model field reference Field types

classTimeField(auto_now=False,auto_now_add=False,**options) A time, represented in Python by a datetime.time instance. Accepts the same auto-population options as DateField. The default form widget for this field is a TimeInput. The admin adds some JavaScript shortcuts.

Reference Settings Core Settings

New in Django 3.2.18. Default: 100 The maximum number of files that may be received via POST in a multipart/form-data encoded request before a SuspiciousOperation (TooManyFiles) is raised. You can set this to None to disable the check.

STATIC_URL

Reference Settings Static Files

Default: None URL to use when referring to static files located in STATIC_ROOT. Example: "static/" or "http://static.example.com/" If not None, this will be used as the base path for asset definitions (the Media class) and the staticfiles app.

Reference

Standard HttpResponse objects are static structures. They are provided with a block of pre-rendered content at time of construction, and while that content can be modified, it isn’t in a form that makes it easy to perform modifications.

Formsets

Topic guide

classBaseFormSet A formset is a layer of abstraction to work with multiple forms on the same page. It can be best compared to a data grid.

Topic guide Formsets

In the rendered HTML, formsets include a prefix on each field’s name. By default, the prefix is 'form', but it can be customized using the formset’s prefix argument.

Topic guide Formsets

Formsets have the following attributes and methods associated with rendering: BaseFormSet.renderer : Specifies the renderer to use for the formset. Defaults to the renderer specified by the FORM_RENDERER setting.

Topic guide Formsets

BaseFormSet.as_table() : Renders the formset with the template_name_table template. BaseFormSet.as_ul() : Renders the formset with the template_name_ul template. Using a formset inside a view is not very different from using a regular Form class.

Topic guide Formsets Using a formset in views and templates

If you manually render fields in the template, you can render can_delete parameter with {{ form.DELETE }}: Similarly, if the formset has the ability to order (can_order=True), it is possible to render it with {{ form.ORDER }}.

Topic guide Formsets Using a formset in views and templates

You are able to use more than one formset in a view if you like. Formsets borrow much of its behavior from forms.

ModelForm

Topic guide Creating forms from models

classModelForm If you’re building a database-driven app, chances are you’ll have forms that map closely to Django models. For instance, you might have a BlogComment model, and you want to create a form that lets people submit comments.

The save() method

Topic guide Creating forms from models ModelForm

Calling save_m2m() is only required if you use save(commit=False). When you use a save() on a form, all data – including many-to-many data – is saved without the need for any additional method calls.

pluralidx

Topic guide Translation Internationalization: in JavaScript codeUsing the JavaScript translation catalog

… function works in a similar way to the pluralize template filter, determining if a given count should use a plural form of a word or not: In the simplest case, if no custom pluralization is needed, this returns false for …