neulab/docprompting-conala huggingface dataset:
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 used when rendering the error list. Any provided classes are added to the default errorlist class. 
  
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. 
  
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. 
  
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. 
  
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. 
  
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.  
  
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 by renderer
  
  
as_text()  
Renders the error list using the template defined by template_name_text. 
  
as_ul()  
Renders the error list using the template defined by template_name_ul. 
 If you’d like to customize the rendering of errors this can be achieved by overriding the template_name attribute or more generally by overriding the default template, see also Overriding built-in form templates.
as_text()  
Renders the error list using the template defined by template_name_text.
as_ul()  
Renders the error list using the template defined by template_name_ul.
error_class  
The CSS classes to be used when rendering the error list. Any provided classes are added to the default errorlist 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.
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 by renderer
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.
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.
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.
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.
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.
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
  Has two optional arguments for validation, max_length and allow_empty_file. If provided, these ensure that the file name is at most the given length, and that validation will succeed even if the file content is empty. To learn more about the UploadedFile object, see the file uploads documentation. When you use a FileField in a form, you must also remember to bind the file data to the form. The max_length error refers to the length of the filename. In the error message for that key, %(max)d will be replaced with the maximum filename length and %(length)d will be replaced with the current filename length.
class FileInput  
 
template_name: 'django/forms/widgets/file.html'
 Renders as: <input type="file" ...>
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 arguments; only path is required:  
path  
The absolute path to the directory whose contents you want listed. This directory must exist. 
  
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. 
  
match  
A regular expression pattern; only files with names matching this expression will be allowed as choices. 
  
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. 
  
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.
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.
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.
match  
A regular expression pattern; only files with names matching this expression will be allowed as choices.
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.
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 allowed, as in Python’s float() function. Error message keys: required, invalid, max_value, min_value
  Takes two optional arguments for validation, max_value and min_value. These control the range of values permitted in the field.
BaseFormSet.as_p()  
Renders the formset with the template_name_p template.
BaseFormSet.as_table()  
Renders the formset with the template_name_table template.
BaseFormSet.as_ul()  
Renders the formset with the template_name_ul template.
BaseFormSet.get_context()  
 New in Django 4.0.  Returns the context for rendering a formset in a template. The available context is:  
formset : The instance of the formset.
BaseFormSet.render(template_name=None, context=None, renderer=None)  
 New in Django 4.0.  The render method is called by __str__ as well as the as_p(), as_ul(), and as_table() methods. All arguments are optional and will default to:  
template_name: template_name
 
context: Value returned by get_context()
 
renderer: Value returned by renderer
BaseFormSet.renderer  
 New in Django 4.0.  Specifies the renderer to use for the formset. Defaults to the renderer specified by the FORM_RENDERER setting.
BaseFormSet.template_name  
 New in Django 4.0.  The name of the template used when calling __str__ or render(). This template renders the formset’s management form and then each form in the formset as per the template defined by the form’s template_name. This is a proxy of as_table by default.
BaseFormSet.template_name_p  
 New in Django 4.0.  The name of the template used when calling as_p(). By default this is 'django/forms/formsets/p.html'. This template renders the formset’s management form and then each form in the formset as per the form’s as_p() method.
BaseFormSet.template_name_table  
 New in Django 4.0.  The name of the template used when calling as_table(). By default this is 'django/forms/formsets/table.html'. This template renders the formset’s management form and then each form in the formset as per the form’s as_table() method.
BaseFormSet.template_name_ul  
 New in Django 4.0.  The name of the template used when calling as_ul(). By default this is 'django/forms/formsets/ul.html'. This template renders the formset’s management form and then each form in the formset as per the form’s as_ul() method.
formset_factory(form, formset=BaseFormSet, extra=1, can_order=False, can_delete=False, max_num=None, validate_max=False, min_num=None, validate_min=False, absolute_max=None, can_delete_extra=True, renderer=None)  
Returns a FormSet class for the given form class. See formsets for example usage.  Changed in Django 3.2: The absolute_max and can_delete_extra arguments were added.   Changed in Django 4.0: The renderer argument was added.
class GenericIPAddressField(**kwargs)  
A field containing either an IPv4 or an IPv6 address.  Default widget: TextInput
 Empty value: '' (an empty string) Normalizes to: A string. IPv6 addresses are normalized as described below. Validates that the given value is a valid IP address. Error message keys: required, invalid
  The IPv6 address normalization follows RFC 4291#section-2.2 section 2.2, including using the IPv4 format suggested in paragraph 3 of that section, like ::ffff:192.0.2.0. For example, 2001:0::0:01 would be normalized to 2001::1, and ::ffff:0a0a:0a0a to ::ffff:10.10.10.10. All characters are converted to lowercase. Takes two optional arguments:  
protocol  
Limits valid inputs to the specified protocol. Accepted values are both (default), IPv4 or IPv6. Matching is case insensitive. 
  
unpack_ipv4  
Unpacks IPv4 mapped addresses like ::ffff:192.0.2.1. If this option is enabled that address would be unpacked to 192.0.2.1. Default is disabled. Can only be used when protocol is set to 'both'.
protocol  
Limits valid inputs to the specified protocol. Accepted values are both (default), IPv4 or IPv6. Matching is case insensitive.
unpack_ipv4  
Unpacks IPv4 mapped addresses like ::ffff:192.0.2.1. If this option is enabled that address would be unpacked to 192.0.2.1. Default is disabled. Can only be used when protocol is set to 'both'.
class HiddenInput  
 
input_type: 'hidden'
 
template_name: 'django/forms/widgets/hidden.html'
 Renders as: <input type="hidden" ...>
  Note that there also is a MultipleHiddenInput widget that encapsulates a set of hidden input elements.
class ImageField(**kwargs)  
 Default widget: ClearableFileInput
 Empty value: None
 Normalizes to: An UploadedFile object that wraps the file content and file name into a single object. Validates that file data has been bound to the form. Also uses FileExtensionValidator to validate that the file extension is supported by Pillow. Error message keys: required, invalid, missing, empty, invalid_image
  Using an ImageField requires that Pillow is installed with support for the image formats you use. If you encounter a corrupt image error when you upload an image, it usually means that Pillow doesn’t understand its format. To fix this, install the appropriate library and reinstall Pillow. When you use an ImageField on a form, you must also remember to bind the file data to the form. After the field has been cleaned and validated, the UploadedFile object will have an additional image attribute containing the Pillow Image instance used to check if the file was a valid image. Pillow closes the underlying file descriptor after verifying an image, so while non-image data attributes, such as format, height, and width, are available, methods that access the underlying image data, such as getdata() or getpixel(), cannot be used without reopening the file. For example: >>> from PIL import Image
>>> from django import forms
>>> from django.core.files.uploadedfile import SimpleUploadedFile
>>> class ImageForm(forms.Form):
...     img = forms.ImageField()
>>> file_data = {'img': SimpleUploadedFile('test.png', <file data>)}
>>> form = ImageForm({}, file_data)
# Pillow closes the underlying file descriptor.
>>> form.is_valid()
True
>>> image_field = form.cleaned_data['img']
>>> image_field.image
<PIL.PngImagePlugin.PngImageFile image mode=RGBA size=191x287 at 0x7F5985045C18>
>>> image_field.image.width
191
>>> image_field.image.height
287
>>> image_field.image.format
'PNG'
>>> image_field.image.getdata()
# Raises AttributeError: 'NoneType' object has no attribute 'seek'.
>>> image = Image.open(image_field)
>>> image.getdata()
<ImagingCore object at 0x7f5984f874b0>
 Additionally, UploadedFile.content_type will be updated with the image’s content type if Pillow can determine it, otherwise it will be set to None.
class IntegerField(**kwargs)  
 Default widget: NumberInput when Field.localize is False, else TextInput. Empty value: None
 Normalizes to: A Python integer. Validates that the given value is an integer. Uses MaxValueValidator and MinValueValidator if max_value and min_value are provided. Leading and trailing whitespace is allowed, as in Python’s int() function. Error message keys: required, invalid, max_value, min_value
  The max_value and min_value error messages may contain %(limit_value)s, which will be substituted by the appropriate limit. Takes two optional arguments for validation:  
max_value 
  
min_value  
These control the range of values permitted in the field.
class JSONField(encoder=None, decoder=None, **kwargs)  
A field which accepts JSON encoded data for a JSONField.  Default widget: Textarea
 Empty value: None
 Normalizes to: A Python representation of the JSON value (usually as a dict, list, or None), depending on JSONField.decoder. Validates that the given value is a valid JSON. Error message keys: required, invalid
  Takes two optional arguments:  
encoder  
A json.JSONEncoder subclass to serialize data types not supported by the standard JSON serializer (e.g. datetime.datetime or UUID). For example, you can use the DjangoJSONEncoder class. Defaults to json.JSONEncoder. 
  
decoder  
A json.JSONDecoder subclass to deserialize the input. Your deserialization may need to account for the fact that you can’t be certain of the input type. For example, you run the risk of returning a datetime that was actually a string that just happened to be in the same format chosen for datetimes. The decoder can be used to validate the input. If json.JSONDecodeError is raised during the deserialization, a ValidationError will be raised. Defaults to json.JSONDecoder. 
  Note If you use a ModelForm, the encoder and decoder from JSONField will be used.   User friendly forms JSONField is not particularly user friendly in most cases. However, it is a useful way to format data from a client-side widget for submission to the server.
decoder  
A json.JSONDecoder subclass to deserialize the input. Your deserialization may need to account for the fact that you can’t be certain of the input type. For example, you run the risk of returning a datetime that was actually a string that just happened to be in the same format chosen for datetimes. The decoder can be used to validate the input. If json.JSONDecodeError is raised during the deserialization, a ValidationError will be raised. Defaults to json.JSONDecoder.
encoder  
A json.JSONEncoder subclass to serialize data types not supported by the standard JSON serializer (e.g. datetime.datetime or UUID). For example, you can use the DjangoJSONEncoder class. Defaults to json.JSONEncoder.
class ModelChoiceField(**kwargs)  
 Default widget: Select
 Empty value: None
 Normalizes to: A model instance. Validates that the given id exists in the queryset. Error message keys: required, invalid_choice
  The invalid_choice error message may contain %(value)s, which will be replaced with the selected choice. Allows the selection of a single model object, suitable for representing a foreign key. Note that the default widget for ModelChoiceField becomes impractical when the number of entries increases. You should avoid using it for more than 100 items. A single argument is required:  
queryset  
A QuerySet of model objects from which the choices for the field are derived and which is used to validate the user’s selection. It’s evaluated when the form is rendered. 
 ModelChoiceField also takes two optional arguments:  
empty_label  
By default the <select> widget used by ModelChoiceField will have an empty choice at the top of the list. You can change the text of this label (which is "---------" by default) with the empty_label attribute, or you can disable the empty label entirely by setting empty_label to None: # A custom empty label
field1 = forms.ModelChoiceField(queryset=..., empty_label="(Nothing)")

# No empty label
field2 = forms.ModelChoiceField(queryset=..., empty_label=None)
 Note that if a ModelChoiceField is required and has a default initial value, no empty choice is created (regardless of the value of empty_label). 
  
to_field_name  
This optional argument is used to specify the field to use as the value of the choices in the field’s widget. Be sure it’s a unique field for the model, otherwise the selected value could match more than one object. By default it is set to None, in which case the primary key of each object will be used. For example: # No custom to_field_name
field1 = forms.ModelChoiceField(queryset=...)
 would yield: <select id="id_field1" name="field1">
<option value="obj1.pk">Object1</option>
<option value="obj2.pk">Object2</option>
...
</select>
 and: # to_field_name provided
field2 = forms.ModelChoiceField(queryset=..., to_field_name="name")
 would yield: <select id="id_field2" name="field2">
<option value="obj1.name">Object1</option>
<option value="obj2.name">Object2</option>
...
</select>
 
 ModelChoiceField also has the attribute:  
iterator  
The iterator class used to generate field choices from queryset. By default, ModelChoiceIterator. 
 The __str__() method of the model will be called to generate string representations of the objects for use in the field’s choices. To provide customized representations, subclass ModelChoiceField and override label_from_instance. This method will receive a model object and should return a string suitable for representing it. For example: from django.forms import ModelChoiceField

class MyModelChoiceField(ModelChoiceField):
    def label_from_instance(self, obj):
        return "My Object #%i" % obj.id
  Changed in Django 4.0: Support for containing %(value)s in the invalid_choice error message was added.
empty_label  
By default the <select> widget used by ModelChoiceField will have an empty choice at the top of the list. You can change the text of this label (which is "---------" by default) with the empty_label attribute, or you can disable the empty label entirely by setting empty_label to None: # A custom empty label
field1 = forms.ModelChoiceField(queryset=..., empty_label="(Nothing)")

# No empty label
field2 = forms.ModelChoiceField(queryset=..., empty_label=None)
 Note that if a ModelChoiceField is required and has a default initial value, no empty choice is created (regardless of the value of empty_label).
iterator  
The iterator class used to generate field choices from queryset. By default, ModelChoiceIterator.
queryset  
A QuerySet of model objects from which the choices for the field are derived and which is used to validate the user’s selection. It’s evaluated when the form is rendered.
to_field_name  
This optional argument is used to specify the field to use as the value of the choices in the field’s widget. Be sure it’s a unique field for the model, otherwise the selected value could match more than one object. By default it is set to None, in which case the primary key of each object will be used. For example: # No custom to_field_name
field1 = forms.ModelChoiceField(queryset=...)
 would yield: <select id="id_field1" name="field1">
<option value="obj1.pk">Object1</option>
<option value="obj2.pk">Object2</option>
...
</select>
 and: # to_field_name provided
field2 = forms.ModelChoiceField(queryset=..., to_field_name="name")
 would yield: <select id="id_field2" name="field2">
<option value="obj1.name">Object1</option>
<option value="obj2.name">Object2</option>
...
</select>
class ModelChoiceIterator(field)  
The default class assigned to the iterator attribute of ModelChoiceField and ModelMultipleChoiceField. An iterable that yields 2-tuple choices from the queryset. A single argument is required:  
field  
The instance of ModelChoiceField or ModelMultipleChoiceField to iterate and yield choices. 
 ModelChoiceIterator has the following method:  
__iter__()  
Yields 2-tuple choices, in the (value, label) format used by ChoiceField.choices. The first value element is a ModelChoiceIteratorValue instance.
__iter__()  
Yields 2-tuple choices, in the (value, label) format used by ChoiceField.choices. The first value element is a ModelChoiceIteratorValue instance.
field  
The instance of ModelChoiceField or ModelMultipleChoiceField to iterate and yield choices.
class ModelChoiceIteratorValue(value, instance)  
Two arguments are required:  
value  
The value of the choice. This value is used to render the value attribute of an HTML <option> element. 
  
instance  
The model instance from the queryset. The instance can be accessed in custom ChoiceWidget.create_option() implementations to adjust the rendered HTML. 
 ModelChoiceIteratorValue has the following method:  
__str__()  
Return value as a string to be rendered in HTML.
instance  
The model instance from the queryset. The instance can be accessed in custom ChoiceWidget.create_option() implementations to adjust the rendered HTML.
value  
The value of the choice. This value is used to render the value attribute of an HTML <option> element.
class ModelMultipleChoiceField(**kwargs)  
 Default widget: SelectMultiple
 Empty value: An empty QuerySet (self.queryset.none()) Normalizes to: A QuerySet of model instances. Validates that every id in the given list of values exists in the queryset. Error message keys: required, invalid_list, invalid_choice, invalid_pk_value
  The invalid_choice message may contain %(value)s and the invalid_pk_value message may contain %(pk)s, which will be substituted by the appropriate values. Allows the selection of one or more model objects, suitable for representing a many-to-many relation. As with ModelChoiceField, you can use label_from_instance to customize the object representations. A single argument is required:  
queryset  
Same as ModelChoiceField.queryset. 
 Takes one optional argument:  
to_field_name  
Same as ModelChoiceField.to_field_name. 
 ModelMultipleChoiceField also has the attribute:  
iterator  
Same as ModelChoiceField.iterator.