Topic guide Form Assets (the Media class) Paths in asset definitions
String paths used to specify assets can be either relative or absolute. If a path starts with /, http:// or https://, it will be interpreted as an absolute path, and left as-is.
713 sections in Django 6.0 Search all versions →
Topic guide Form Assets (the Media class) Paths in asset definitions
String paths used to specify assets can be either relative or absolute. If a path starts with /, http:// or https://, it will be interpreted as an absolute path, and left as-is.
Topic guide Form Assets (the Media class) Paths in asset definitions
Assets may also be object-based, using Script. Furthermore, these allow you to pass custom HTML attributes: If this Media definition were to be rendered, it would become the following HTML: Changed in Django 5.2: The object class Script was added.
Topic guide Form Assets (the Media class) Media objects
If you only want files of a particular type, you can use the subscript operator to filter out a medium of interest.
Topic guide Form Assets (the Media class) Media objects
Media objects can also be added together. When two Media objects are added, the resulting Media object contains the union of the assets specified by both:
Topic guide Form Assets (the Media class) Media objects
The order in which assets are inserted into the DOM is often important. For example, you may have a script that depends on jQuery.
Reference The form rendering API Built-in-template form renderers
Templates for the built-in widgets are located in django/forms/jinja2 and installed apps can provide templates in a jinja2 directory. To use this backend, all the forms and widgets in your project and its third-party apps must have Jinja2 templates.
Reference The form rendering API
Formset templates receive a context from BaseFormSet.get_context(). By default, formsets receive a dictionary with the following values: formset: The formset instance.
Reference The form rendering API
Field templates receive a context from BoundField.get_context(). By default, fields receive a dictionary with the following values: field: The BoundField.
Reference The form rendering API
This is a dictionary that contains values like: name value attrs is_hidden template_name Some widgets add further information to the context. For instance, all widgets that subclass Input defines widget['type'] and MultiWidget defines widget['subwidgets'] for looping purposes.
Reference The form rendering API
BaseFormSet.template_name To override formset templates, you must use the TemplatesSetting renderer. Then overriding formset templates works the same as overriding any other template in your project.
Reference The form rendering API
Field.template_name To override field templates, you must use the TemplatesSetting renderer. Then overriding field templates works the same as overriding any other template in your project.
Reference The form rendering API
Built-in widget templates are stored in the django/forms/widgets path. You can provide a custom template for input.html by defining django/forms/widgets/input.html, for example. See Built-in widgets for the name of each widget’s template.
Reference PostgreSQL specific form fields and widgets Fields
This group of fields all share similar functionality for accepting range data. They are based on MultiValueField. They treat one omitted value as an unbounded range. They also validate that the lower bound is not greater than the upper bound.
Reference PostgreSQL specific form fields and widgets FieldsRange Fields
classIntegerRangeField : Based on IntegerField and translates its input into django.db.backends.postgresql.psycopg_any.NumericRange. Default for IntegerRangeField and BigIntegerRangeField.
Reference PostgreSQL specific form fields and widgets FieldsRange Fields
classDecimalRangeField : Based on DecimalField and translates its input into django.db.backends.postgresql.psycopg_any.NumericRange. Default for DecimalRangeField.
Reference PostgreSQL specific form fields and widgets FieldsRange Fields
classDateTimeRangeField : Based on DateTimeField and translates its input into django.db.backends.postgresql.psycopg_any.DateTimeTZRange. Default for DateTimeRangeField.
Reference PostgreSQL specific form fields and widgets FieldsRange Fields
classDateRangeField : Based on DateField and translates its input into django.db.backends.postgresql.psycopg_any.DateRange. Default for DateRangeField.
Reference PostgreSQL specific form fields and widgets Widgets
classRangeWidget(base_widget,attrs=None) : Widget used by all of the range fields. Based on MultiWidget.