doc_content stringlengths 1 386k | doc_id stringlengths 5 188 |
|---|---|
Signal.connect(receiver, sender=None, weak=True, dispatch_uid=None) [source]
Parameters:
receiver – The callback function which will be connected to this signal. See Receiver functions for more information.
sender – Specifies a particular sender to receive signals from. See Connecting to signals sent by speci... | django.topics.signals#django.dispatch.Signal.connect |
Signal.disconnect(receiver=None, sender=None, dispatch_uid=None) [source] | django.topics.signals#django.dispatch.Signal.disconnect |
Signal.send(sender, **kwargs) [source] | django.topics.signals#django.dispatch.Signal.send |
Signal.send_robust(sender, **kwargs) [source] | django.topics.signals#django.dispatch.Signal.send_robust |
django.contrib.auth This document provides API reference material for the components of Django’s authentication system. For more details on the usage of these components or how to customize authentication and authorization see the authentication topic guide.
User model
class models.User
Fields
class models.User ... | django.ref.contrib.auth |
django.contrib.humanize A set of Django template filters useful for adding a “human touch” to data. To activate these filters, add 'django.contrib.humanize' to your INSTALLED_APPS setting. Once you’ve done that, use {% load humanize %} in a template, and you’ll have access to the following filters. apnumber For numbers... | django.ref.contrib.humanize |
django.contrib.postgres PostgreSQL has a number of features which are not shared by the other databases Django supports. This optional module contains model fields and form fields for a number of PostgreSQL specific data types. Note Django is, and will continue to be, a database-agnostic web framework. We would encour... | django.ref.contrib.postgres.index |
class FlatpageFallbackMiddleware
Each time any Django application raises a 404 error, this middleware checks the flatpages database for the requested URL as a last resort. Specifically, it checks for a flatpage with the given URL with a site ID that corresponds to the SITE_ID setting. If it finds a match, it follows ... | django.ref.contrib.flatpages#django.contrib.flatpages.middleware.FlatpageFallbackMiddleware |
class FlatPage
Flatpages are represented by a standard Django model, which lives in django/contrib/flatpages/models.py. You can access flatpage objects via the Django database API. | django.ref.contrib.flatpages#django.contrib.flatpages.models.FlatPage |
class FlatPageSitemap
The sitemaps.FlatPageSitemap class looks at all publicly visible flatpages defined for the current SITE_ID (see the sites documentation) and creates an entry in the sitemap. These entries include only the location attribute – not lastmod, changefreq or priority. | django.ref.contrib.flatpages#django.contrib.flatpages.sitemaps.FlatPageSitemap |
Forms Detailed form API reference. For introductory material, see the Working with forms topic guide.
The Forms API Bound and unbound forms Using forms to validate data Initial form values Checking which form data has changed Accessing the fields from the form Accessing “clean” data Outputting forms as HTML More gran... | django.ref.forms.index |
class BooleanField(**kwargs)
Default widget: CheckboxInput
Empty value: False
Normalizes to: A Python True or False value. Validates that the value is True (e.g. the check box is checked) if the field has required=True. Error message keys: required
Note Since all Field subclasses have required=True by default, ... | django.ref.forms.fields#django.forms.BooleanField |
class BoundField
Used to display HTML or access attributes for a single field of a Form instance. The __str__() method of this object displays the HTML for this field. | django.ref.forms.api#django.forms.BoundField |
BoundField.as_hidden(attrs=None, **kwargs)
Returns a string of HTML for representing this as an <input type="hidden">. **kwargs are passed to as_widget(). This method is primarily used internally. You should use a widget instead. | django.ref.forms.api#django.forms.BoundField.as_hidden |
BoundField.as_widget(widget=None, attrs=None, only_initial=False)
Renders the field by rendering the passed widget, adding any HTML attributes passed as attrs. If no widget is specified, then the field’s default widget will be used. only_initial is used by Django internals and should not be set explicitly. | django.ref.forms.api#django.forms.BoundField.as_widget |
BoundField.auto_id
The HTML ID attribute for this BoundField. Returns an empty string if Form.auto_id is False. | django.ref.forms.api#django.forms.BoundField.auto_id |
BoundField.css_classes(extra_classes=None)
When you use Django’s rendering shortcuts, CSS classes are used to indicate required form fields or fields that contain errors. If you’re manually rendering a form, you can access these CSS classes using the css_classes method: >>> f = ContactForm(data={'message': ''})
>>> f... | django.ref.forms.api#django.forms.BoundField.css_classes |
BoundField.data
This property returns the data for this BoundField extracted by the widget’s value_from_datadict() method, or None if it wasn’t given: >>> unbound_form = ContactForm()
>>> print(unbound_form['subject'].data)
None
>>> bound_form = ContactForm(data={'subject': 'My Subject'})
>>> print(bound_form['subjec... | django.ref.forms.api#django.forms.BoundField.data |
BoundField.errors
A list-like object that is displayed as an HTML <ul class="errorlist"> when printed: >>> data = {'subject': 'hi', 'message': '', 'sender': '', 'cc_myself': ''}
>>> f = ContactForm(data, auto_id=False)
>>> print(f['message'])
<input type="text" name="message" required>
>>> f['message'].errors
['This ... | django.ref.forms.api#django.forms.BoundField.errors |
BoundField.field
The form Field instance from the form class that this BoundField wraps. | django.ref.forms.api#django.forms.BoundField.field |
BoundField.form
The Form instance this BoundField is bound to. | django.ref.forms.api#django.forms.BoundField.form |
BoundField.help_text
The help_text of the field. | django.ref.forms.api#django.forms.BoundField.help_text |
BoundField.html_name
The name that will be used in the widget’s HTML name attribute. It takes the form prefix into account. | django.ref.forms.api#django.forms.BoundField.html_name |
BoundField.id_for_label
Use this property to render the ID of this field. For example, if you are manually constructing a <label> in your template (despite the fact that label_tag() will do this for you): <label for="{{ form.my_field.id_for_label }}">...</label>{{ my_field }}
By default, this will be the field’s nam... | django.ref.forms.api#django.forms.BoundField.id_for_label |
BoundField.initial
Use BoundField.initial to retrieve initial data for a form field. It retrieves the data from Form.initial if present, otherwise trying Field.initial. Callable values are evaluated. See Initial form values for more examples. BoundField.initial caches its return value, which is useful especially when... | django.ref.forms.api#django.forms.BoundField.initial |
BoundField.is_hidden
Returns True if this BoundField’s widget is hidden. | django.ref.forms.api#django.forms.BoundField.is_hidden |
BoundField.label
The label of the field. This is used in label_tag(). | django.ref.forms.api#django.forms.BoundField.label |
BoundField.label_tag(contents=None, attrs=None, label_suffix=None)
Renders a label tag for the form field using the template specified by Form.template_name_label. The available context is:
field: This instance of the BoundField.
contents: By default a concatenated string of BoundField.label and Form.label_suffix ... | django.ref.forms.api#django.forms.BoundField.label_tag |
BoundField.name
The name of this field in the form: >>> f = ContactForm()
>>> print(f['subject'].name)
subject
>>> print(f['message'].name)
message | django.ref.forms.api#django.forms.BoundField.name |
BoundField.value()
Use this method to render the raw value of this field as it would be rendered by a Widget: >>> initial = {'subject': 'welcome'}
>>> unbound_form = ContactForm(initial=initial)
>>> bound_form = ContactForm(data={'subject': 'hi'}, initial=initial)
>>> print(unbound_form['subject'].value())
welcome
>>... | django.ref.forms.api#django.forms.BoundField.value |
BoundField.widget_type
Returns the lowercased class name of the wrapped field’s widget, with any trailing input or widget removed. This may be used when building forms where the layout is dependent upon the widget type. For example: {% for field in form %}
{% if field.widget_type == 'checkbox' %}
# render... | django.ref.forms.api#django.forms.BoundField.widget_type |
class CharField(**kwargs)
Default widget: TextInput
Empty value: Whatever you’ve given as empty_value. Normalizes to: A string. Uses MaxLengthValidator and MinLengthValidator if max_length and min_length are provided. Otherwise, all inputs are valid. Error message keys: required, max_length, min_length
Has four o... | django.ref.forms.fields#django.forms.CharField |
empty_value
The value to use to represent “empty”. Defaults to an empty string. | django.ref.forms.fields#django.forms.CharField.empty_value |
max_length | django.ref.forms.fields#django.forms.CharField.max_length |
min_length
If provided, these arguments ensure that the string is at most or at least the given length. | django.ref.forms.fields#django.forms.CharField.min_length |
strip
If True (default), the value will be stripped of leading and trailing whitespace. | django.ref.forms.fields#django.forms.CharField.strip |
class CheckboxInput
input_type: 'checkbox'
template_name: 'django/forms/widgets/checkbox.html'
Renders as: <input type="checkbox" ...>
Takes one optional argument:
check_test
A callable that takes the value of the CheckboxInput and returns True if the checkbox should be checked for that value. | django.ref.forms.widgets#django.forms.CheckboxInput |
check_test
A callable that takes the value of the CheckboxInput and returns True if the checkbox should be checked for that value. | django.ref.forms.widgets#django.forms.CheckboxInput.check_test |
class CheckboxSelectMultiple
template_name: 'django/forms/widgets/checkbox_select.html'
option_template_name: 'django/forms/widgets/checkbox_option.html'
Similar to SelectMultiple, but rendered as a list of checkboxes: <div>
<div><input type="checkbox" name="..." ></div>
...
</div>
The outer <div> containe... | django.ref.forms.widgets#django.forms.CheckboxSelectMultiple |
class ChoiceField(**kwargs)
Default widget: Select
Empty value: '' (an empty string) Normalizes to: A string. Validates that the given value exists in the list of choices. Error message keys: required, invalid_choice
The invalid_choice error message may contain %(value)s, which will be replaced with the selected ... | django.ref.forms.fields#django.forms.ChoiceField |
choices
Either an iterable of 2-tuples to use as choices for this field, enumeration choices, or a callable that returns such an iterable. This argument accepts the same formats as the choices argument to a model field. See the model field reference documentation on choices for more details. If the argument is a call... | django.ref.forms.fields#django.forms.ChoiceField.choices |
class ClearableFileInput
template_name: 'django/forms/widgets/clearable_file_input.html'
Renders as: <input type="file" ...> with an additional checkbox input to clear the field’s value, if the field is not required and has initial data. | django.ref.forms.widgets#django.forms.ClearableFileInput |
class ComboField(**kwargs)
Default widget: TextInput
Empty value: '' (an empty string) Normalizes to: A string. Validates the given value against each of the fields specified as an argument to the ComboField. Error message keys: required, invalid
Takes one extra required argument:
fields
The list of fields th... | django.ref.forms.fields#django.forms.ComboField |
fields
The list of fields that should be used to validate the field’s value (in the order in which they are provided). >>> from django.forms import ComboField
>>> f = ComboField(fields=[CharField(max_length=20), EmailField()])
>>> f.clean('test@example.com')
'test@example.com'
>>> f.clean('longemailaddress@example.co... | django.ref.forms.fields#django.forms.ComboField.fields |
class DateField(**kwargs)
Default widget: DateInput
Empty value: None
Normalizes to: A Python datetime.date object. Validates that the given value is either a datetime.date, datetime.datetime or string formatted in a particular date format. Error message keys: required, invalid
Takes one optional argument:
inp... | django.ref.forms.fields#django.forms.DateField |
input_formats
A list of formats used to attempt to convert a string to a valid datetime.date object. | django.ref.forms.fields#django.forms.DateField.input_formats |
class DateInput
input_type: 'text'
template_name: 'django/forms/widgets/date.html'
Renders as: <input type="text" ...>
Takes same arguments as TextInput, with one more optional argument:
format
The format in which this field’s initial value will be displayed.
If no format argument is provided, the defaul... | django.ref.forms.widgets#django.forms.DateInput |
format
The format in which this field’s initial value will be displayed. | django.ref.forms.widgets#django.forms.DateInput.format |
class DateTimeField(**kwargs)
Default widget: DateTimeInput
Empty value: None
Normalizes to: A Python datetime.datetime object. Validates that the given value is either a datetime.datetime, datetime.date or string formatted in a particular datetime format. Error message keys: required, invalid
Takes one optional... | django.ref.forms.fields#django.forms.DateTimeField |
input_formats
A list of formats used to attempt to convert a string to a valid datetime.datetime object, in addition to ISO 8601 formats. | django.ref.forms.fields#django.forms.DateTimeField.input_formats |
class DateTimeInput
input_type: 'text'
template_name: 'django/forms/widgets/datetime.html'
Renders as: <input type="text" ...>
Takes same arguments as TextInput, with one more optional argument:
format
The format in which this field’s initial value will be displayed.
If no format argument is provided, th... | django.ref.forms.widgets#django.forms.DateTimeInput |
format
The format in which this field’s initial value will be displayed. | django.ref.forms.widgets#django.forms.DateTimeInput.format |
class DecimalField(**kwargs)
Default widget: NumberInput when Field.localize is False, else TextInput. Empty value: None
Normalizes to: A Python decimal. Validates that the given value is a decimal. Uses MaxValueValidator and MinValueValidator if max_value and min_value are provided. Leading and trailing whitespace... | django.ref.forms.fields#django.forms.DecimalField |
decimal_places
The maximum number of decimal places permitted. | django.ref.forms.fields#django.forms.DecimalField.decimal_places |
max_digits
The maximum number of digits (those before the decimal point plus those after the decimal point, with leading zeros stripped) permitted in the value. | django.ref.forms.fields#django.forms.DecimalField.max_digits |
max_value | django.ref.forms.fields#django.forms.DecimalField.max_value |
min_value
These control the range of values permitted in the field, and should be given as decimal.Decimal values. | django.ref.forms.fields#django.forms.DecimalField.min_value |
class DurationField(**kwargs)
Default widget: TextInput
Empty value: None
Normalizes to: A Python timedelta. Validates that the given value is a string which can be converted into a timedelta. The value must be between datetime.timedelta.min and datetime.timedelta.max. Error message keys: required, invalid, overfl... | django.ref.forms.fields#django.forms.DurationField |
class EmailField(**kwargs)
Default widget: EmailInput
Empty value: Whatever you’ve given as empty_value. Normalizes to: A string. Uses EmailValidator to validate that the given value is a valid email address, using a moderately complex regular expression. Error message keys: required, invalid
Has three optional a... | django.ref.forms.fields#django.forms.EmailField |
class EmailInput
input_type: 'email'
template_name: 'django/forms/widgets/email.html'
Renders as: <input type="email" ...> | django.ref.forms.widgets#django.forms.EmailInput |
class ErrorList(initlist=None, error_class=None, renderer=None)
By default, forms use django.forms.utils.ErrorList to format validation errors. ErrorList is a list like object where initlist is the list of errors. In addition this class has the following attributes and methods.
error_class
The CSS classes to be u... | django.ref.forms.api#django.forms.ErrorList |
as_text()
Renders the error list using the template defined by template_name_text. | django.ref.forms.api#django.forms.ErrorList.as_text |
as_ul()
Renders the error list using the template defined by template_name_ul. | django.ref.forms.api#django.forms.ErrorList.as_ul |
error_class
The CSS classes to be used when rendering the error list. Any provided classes are added to the default errorlist class. | django.ref.forms.api#django.forms.ErrorList.error_class |
get_context()
New in Django 4.0. Return context for rendering of errors in a template. The available context is:
errors : A list of the errors.
error_class : A string of CSS classes. | django.ref.forms.api#django.forms.ErrorList.get_context |
render(template_name=None, context=None, renderer=None)
New in Django 4.0. The render method is called by __str__ as well as by the as_ul() method. All arguments are optional and will default to:
template_name: Value returned by template_name
context: Value returned by get_context()
renderer: Value returned b... | django.ref.forms.api#django.forms.ErrorList.render |
renderer
New in Django 4.0. Specifies the renderer to use for ErrorList. Defaults to None which means to use the default renderer specified by the FORM_RENDERER setting. | django.ref.forms.api#django.forms.ErrorList.renderer |
template_name
New in Django 4.0. The name of the template used when calling __str__ or render(). By default this is 'django/forms/errors/list/default.html' which is a proxy for the 'ul.html' template. | django.ref.forms.api#django.forms.ErrorList.template_name |
template_name_text
New in Django 4.0. The name of the template used when calling as_text(). By default this is 'django/forms/errors/list/text.html'. This template renders the errors as a list of bullet points. | django.ref.forms.api#django.forms.ErrorList.template_name_text |
template_name_ul
New in Django 4.0. The name of the template used when calling as_ul(). By default this is 'django/forms/errors/list/ul.html'. This template renders the errors in <li> tags with a wrapping <ul> with the CSS classes as defined by error_class. | django.ref.forms.api#django.forms.ErrorList.template_name_ul |
class Field(**kwargs) | django.ref.forms.fields#django.forms.Field |
Field.clean(value) | django.ref.forms.fields#django.forms.Field.clean |
Field.disabled | django.ref.forms.fields#django.forms.Field.disabled |
Field.error_messages | django.ref.forms.fields#django.forms.Field.error_messages |
Field.get_bound_field(form, field_name)
Takes an instance of Form and the name of the field. The return value will be used when accessing the field in a template. Most likely it will be an instance of a subclass of BoundField. | django.ref.forms.api#django.forms.Field.get_bound_field |
Field.has_changed() | django.ref.forms.fields#django.forms.Field.has_changed |
Field.help_text | django.ref.forms.fields#django.forms.Field.help_text |
Field.initial | django.ref.forms.fields#django.forms.Field.initial |
Field.label | django.ref.forms.fields#django.forms.Field.label |
Field.label_suffix | django.ref.forms.fields#django.forms.Field.label_suffix |
Field.localize | django.ref.forms.fields#django.forms.Field.localize |
Field.required | django.ref.forms.fields#django.forms.Field.required |
Field.validators | django.ref.forms.fields#django.forms.Field.validators |
Field.widget | django.ref.forms.fields#django.forms.Field.widget |
class FileField(**kwargs)
Default widget: ClearableFileInput
Empty value: None
Normalizes to: An UploadedFile object that wraps the file content and file name into a single object. Can validate that non-empty file data has been bound to the form. Error message keys: required, invalid, missing, empty, max_length
... | django.ref.forms.fields#django.forms.FileField |
class FileInput
template_name: 'django/forms/widgets/file.html'
Renders as: <input type="file" ...> | django.ref.forms.widgets#django.forms.FileInput |
class FilePathField(**kwargs)
Default widget: Select
Empty value: '' (an empty string) Normalizes to: A string. Validates that the selected choice exists in the list of choices. Error message keys: required, invalid_choice
The field allows choosing from files inside a certain directory. It takes five extra argume... | django.ref.forms.fields#django.forms.FilePathField |
allow_files
Optional. Either True or False. Default is True. Specifies whether files in the specified location should be included. Either this or allow_folders must be True. | django.ref.forms.fields#django.forms.FilePathField.allow_files |
allow_folders
Optional. Either True or False. Default is False. Specifies whether folders in the specified location should be included. Either this or allow_files must be True. | django.ref.forms.fields#django.forms.FilePathField.allow_folders |
match
A regular expression pattern; only files with names matching this expression will be allowed as choices. | django.ref.forms.fields#django.forms.FilePathField.match |
path
The absolute path to the directory whose contents you want listed. This directory must exist. | django.ref.forms.fields#django.forms.FilePathField.path |
recursive
If False (the default) only the direct contents of path will be offered as choices. If True, the directory will be descended into recursively and all descendants will be listed as choices. | django.ref.forms.fields#django.forms.FilePathField.recursive |
class FloatField(**kwargs)
Default widget: NumberInput when Field.localize is False, else TextInput. Empty value: None
Normalizes to: A Python float. Validates that the given value is a float. Uses MaxValueValidator and MinValueValidator if max_value and min_value are provided. Leading and trailing whitespace is al... | django.ref.forms.fields#django.forms.FloatField |
class Form | django.ref.forms.api#django.forms.Form |
Form.add_error(field, error) | django.ref.forms.api#django.forms.Form.add_error |
Form.as_p() | django.ref.forms.api#django.forms.Form.as_p |
Form.as_table() | django.ref.forms.api#django.forms.Form.as_table |
Form.as_ul() | django.ref.forms.api#django.forms.Form.as_ul |
Form.auto_id | django.ref.forms.api#django.forms.Form.auto_id |
Form.changed_data | django.ref.forms.api#django.forms.Form.changed_data |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.