neulab/docprompting-conala huggingface dataset:
inlineformset_factory(parent_model, model, form=ModelForm, formset=BaseInlineFormSet, fk_name=None, fields=None, exclude=None, extra=3, can_order=False, can_delete=True, max_num=None, formfield_callback=None, widgets=None, validate_max=False, localized_fields=None, labels=None, help_texts=None, error_messages=None, min_num=None, validate_min=False, field_classes=None, absolute_max=None, can_delete_extra=True, renderer=None)  
Returns an InlineFormSet using modelformset_factory() with defaults of formset=BaseInlineFormSet, can_delete=True, and extra=3. If your model has more than one ForeignKey to the parent_model, you must specify a fk_name. See Inline 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.
modelform_factory(model, form=ModelForm, fields=None, exclude=None, formfield_callback=None, widgets=None, localized_fields=None, labels=None, help_texts=None, error_messages=None, field_classes=None)  
Returns a ModelForm class for the given model. You can optionally pass a form argument to use as a starting point for constructing the ModelForm. fields is an optional list of field names. If provided, only the named fields will be included in the returned fields. exclude is an optional list of field names. If provided, the named fields will be excluded from the returned fields, even if they are listed in the fields argument. formfield_callback is a callable that takes a model field and returns a form field. widgets is a dictionary of model field names mapped to a widget. localized_fields is a list of names of fields which should be localized. labels is a dictionary of model field names mapped to a label. help_texts is a dictionary of model field names mapped to a help text. error_messages is a dictionary of model field names mapped to a dictionary of error messages. field_classes is a dictionary of model field names mapped to a form field class. See ModelForm factory function for example usage. You must provide the list of fields explicitly, either via keyword arguments fields or exclude, or the corresponding attributes on the form’s inner Meta class. See Selecting the fields to use for more information. Omitting any definition of the fields to use will result in an ImproperlyConfigured exception.
modelformset_factory(model, form=ModelForm, formfield_callback=None, formset=BaseModelFormSet, extra=1, can_delete=False, can_order=False, max_num=None, fields=None, exclude=None, widgets=None, validate_max=False, localized_fields=None, labels=None, help_texts=None, error_messages=None, min_num=None, validate_min=False, field_classes=None, absolute_max=None, can_delete_extra=True, renderer=None)  
Returns a FormSet class for the given model class. Arguments model, form, fields, exclude, formfield_callback, widgets, localized_fields, labels, help_texts, error_messages, and field_classes are all passed through to modelform_factory(). Arguments formset, extra, can_delete, can_order, max_num, validate_max, min_num, validate_min, absolute_max, can_delete_extra, and renderer are passed through to formset_factory(). See formsets for details. See Model 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 MultipleChoiceField(**kwargs)  
 Default widget: SelectMultiple
 Empty value: [] (an empty list) Normalizes to: A list of strings. Validates that every value in the given list of values exists in the list of choices. Error message keys: required, invalid_choice, invalid_list
  The invalid_choice error message may contain %(value)s, which will be replaced with the selected choice. Takes one extra required argument, choices, as for ChoiceField.
class MultipleHiddenInput  
 
template_name: 'django/forms/widgets/multiple_hidden.html'
 Renders as: multiple <input type="hidden" ...> tags  A widget that handles multiple hidden widgets for fields that have a list of values.
class MultiValueField(fields=(), **kwargs)  
 Default widget: TextInput
 Empty value: '' (an empty string) Normalizes to: the type returned by the compress method of the subclass. Validates the given value against each of the fields specified as an argument to the MultiValueField. Error message keys: required, invalid, incomplete
  Aggregates the logic of multiple fields that together produce a single value. This field is abstract and must be subclassed. In contrast with the single-value fields, subclasses of MultiValueField must not implement clean() but instead - implement compress(). Takes one extra required argument:  
fields  
A tuple of fields whose values are cleaned and subsequently combined into a single value. Each value of the field is cleaned by the corresponding field in fields – the first value is cleaned by the first field, the second value is cleaned by the second field, etc. Once all fields are cleaned, the list of clean values is combined into a single value by compress(). 
 Also takes some optional arguments:  
require_all_fields  
Defaults to True, in which case a required validation error will be raised if no value is supplied for any field. When set to False, the Field.required attribute can be set to False for individual fields to make them optional. If no value is supplied for a required field, an incomplete validation error will be raised. A default incomplete error message can be defined on the MultiValueField subclass, or different messages can be defined on each individual field. For example: from django.core.validators import RegexValidator

class PhoneField(MultiValueField):
    def __init__(self, **kwargs):
        # Define one message for all fields.
        error_messages = {
            'incomplete': 'Enter a country calling code and a phone number.',
        }
        # Or define a different message for each field.
        fields = (
            CharField(
                error_messages={'incomplete': 'Enter a country calling code.'},
                validators=[
                    RegexValidator(r'^[0-9]+$', 'Enter a valid country calling code.'),
                ],
            ),
            CharField(
                error_messages={'incomplete': 'Enter a phone number.'},
                validators=[RegexValidator(r'^[0-9]+$', 'Enter a valid phone number.')],
            ),
            CharField(
                validators=[RegexValidator(r'^[0-9]+$', 'Enter a valid extension.')],
                required=False,
            ),
        )
        super().__init__(
            error_messages=error_messages, fields=fields,
            require_all_fields=False, **kwargs
        )
 
  
widget  
Must be a subclass of django.forms.MultiWidget. Default value is TextInput, which probably is not very useful in this case. 
  
compress(data_list)  
Takes a list of valid values and returns a “compressed” version of those values – in a single value. For example, SplitDateTimeField is a subclass which combines a time field and a date field into a datetime object. This method must be implemented in the subclasses.
compress(data_list)  
Takes a list of valid values and returns a “compressed” version of those values – in a single value. For example, SplitDateTimeField is a subclass which combines a time field and a date field into a datetime object. This method must be implemented in the subclasses.
fields  
A tuple of fields whose values are cleaned and subsequently combined into a single value. Each value of the field is cleaned by the corresponding field in fields – the first value is cleaned by the first field, the second value is cleaned by the second field, etc. Once all fields are cleaned, the list of clean values is combined into a single value by compress().
require_all_fields  
Defaults to True, in which case a required validation error will be raised if no value is supplied for any field. When set to False, the Field.required attribute can be set to False for individual fields to make them optional. If no value is supplied for a required field, an incomplete validation error will be raised. A default incomplete error message can be defined on the MultiValueField subclass, or different messages can be defined on each individual field. For example: from django.core.validators import RegexValidator

class PhoneField(MultiValueField):
    def __init__(self, **kwargs):
        # Define one message for all fields.
        error_messages = {
            'incomplete': 'Enter a country calling code and a phone number.',
        }
        # Or define a different message for each field.
        fields = (
            CharField(
                error_messages={'incomplete': 'Enter a country calling code.'},
                validators=[
                    RegexValidator(r'^[0-9]+$', 'Enter a valid country calling code.'),
                ],
            ),
            CharField(
                error_messages={'incomplete': 'Enter a phone number.'},
                validators=[RegexValidator(r'^[0-9]+$', 'Enter a valid phone number.')],
            ),
            CharField(
                validators=[RegexValidator(r'^[0-9]+$', 'Enter a valid extension.')],
                required=False,
            ),
        )
        super().__init__(
            error_messages=error_messages, fields=fields,
            require_all_fields=False, **kwargs
        )
widget  
Must be a subclass of django.forms.MultiWidget. Default value is TextInput, which probably is not very useful in this case.
decompress(value)  
This method takes a single “compressed” value from the field and returns a list of “decompressed” values. The input value can be assumed valid, but not necessarily non-empty. This method must be implemented by the subclass, and since the value may be empty, the implementation must be defensive. The rationale behind “decompression” is that it is necessary to “split” the combined value of the form field into the values for each widget. An example of this is how SplitDateTimeWidget turns a datetime value into a list with date and time split into two separate values: from django.forms import MultiWidget

class SplitDateTimeWidget(MultiWidget):

    # ...

    def decompress(self, value):
        if value:
            return [value.date(), value.time()]
        return [None, None]
  Tip Note that MultiValueField has a complementary method compress() with the opposite responsibility - to combine cleaned values of all member fields into one.
get_context(name, value, attrs)  
In addition to the 'widget' key described in Widget.get_context(), MultiWidget adds a widget['subwidgets'] key. These can be looped over in the widget template: {% for subwidget in widget.subwidgets %}
    {% include subwidget.template_name with widget=subwidget %}
{% endfor %}
widgets  
An iterable containing the widgets needed. For example: >>> from django.forms import MultiWidget, TextInput
>>> widget = MultiWidget(widgets=[TextInput, TextInput])
>>> widget.render('name', ['john', 'paul'])
'<input type="text" name="name_0" value="john"><input type="text" name="name_1" value="paul">'
 You may provide a dictionary in order to specify custom suffixes for the name attribute on each subwidget. In this case, for each (key, widget) pair, the key will be appended to the name of the widget in order to generate the attribute value. You may provide the empty string ('') for a single key, in order to suppress the suffix for one widget. For example: >>> widget = MultiWidget(widgets={'': TextInput, 'last': TextInput})
>>> widget.render('name', ['john', 'paul'])
'<input type="text" name="name" value="john"><input type="text" name="name_last" value="paul">'
class NullBooleanField(**kwargs)  
 Default widget: NullBooleanSelect
 Empty value: None
 Normalizes to: A Python True, False or None value. Validates nothing (i.e., it never raises a ValidationError).  NullBooleanField may be used with widgets such as Select or RadioSelect by providing the widget choices: NullBooleanField(
    widget=Select(
        choices=[
            ('', 'Unknown'),
            (True, 'Yes'),
            (False, 'No'),
        ]
    )
)
class NullBooleanSelect  
 
template_name: 'django/forms/widgets/select.html'
 
option_template_name: 'django/forms/widgets/select_option.html'
  Select widget with options ‘Unknown’, ‘Yes’ and ‘No’
class NumberInput  
 
input_type: 'number'
 
template_name: 'django/forms/widgets/number.html'
 Renders as: <input type="number" ...>
  Beware that not all browsers support entering localized numbers in number input types. Django itself avoids using them for fields having their localize property set to True.
class PasswordInput  
 
input_type: 'password'
 
template_name: 'django/forms/widgets/password.html'
 Renders as: <input type="password" ...>
  Takes one optional argument:  
render_value  
Determines whether the widget will have a value filled in when the form is re-displayed after a validation error (default is False).
render_value  
Determines whether the widget will have a value filled in when the form is re-displayed after a validation error (default is False).
class RadioSelect  
 
template_name: 'django/forms/widgets/radio.html'
 
option_template_name: 'django/forms/widgets/radio_option.html'
  Similar to Select, but rendered as a list of radio buttons within <div> tags: <div>
  <div><input type="radio" name="..."></div>
  ...
</div>
  Changed in Django 4.0: So they are announced more concisely by screen readers, radio buttons were changed to render in <div> tags.  For more granular control over the generated markup, you can loop over the radio buttons in the template. Assuming a form myform with a field beatles that uses a RadioSelect as its widget: <fieldset>
    <legend>{{ myform.beatles.label }}</legend>
    {% for radio in myform.beatles %}
    <div class="myradio">
        {{ radio }}
    </div>
    {% endfor %}
</fieldset>
 This would generate the following HTML: <fieldset>
    <legend>Radio buttons</legend>
    <div class="myradio">
        <label for="id_beatles_0"><input id="id_beatles_0" name="beatles" type="radio" value="john" required> John</label>
    </div>
    <div class="myradio">
        <label for="id_beatles_1"><input id="id_beatles_1" name="beatles" type="radio" value="paul" required> Paul</label>
    </div>
    <div class="myradio">
        <label for="id_beatles_2"><input id="id_beatles_2" name="beatles" type="radio" value="george" required> George</label>
    </div>
    <div class="myradio">
        <label for="id_beatles_3"><input id="id_beatles_3" name="beatles" type="radio" value="ringo" required> Ringo</label>
    </div>
</fieldset>
 That included the <label> tags. To get more granular, you can use each radio button’s tag, choice_label and id_for_label attributes. For example, this template… <fieldset>
    <legend>{{ myform.beatles.label }}</legend>
    {% for radio in myform.beatles %}
    <label for="{{ radio.id_for_label }}">
        {{ radio.choice_label }}
        <span class="radio">{{ radio.tag }}</span>
    </label>
    {% endfor %}
</fieldset>
 …will result in the following HTML: <fieldset>
    <legend>Radio buttons</legend>
    <label for="id_beatles_0">
        John
        <span class="radio"><input id="id_beatles_0" name="beatles" type="radio" value="john" required></span>
    </label>
    <label for="id_beatles_1">
        Paul
        <span class="radio"><input id="id_beatles_1" name="beatles" type="radio" value="paul" required></span>
    </label>
    <label for="id_beatles_2">
        George
        <span class="radio"><input id="id_beatles_2" name="beatles" type="radio" value="george" required></span>
    </label>
    <label for="id_beatles_3">
        Ringo
        <span class="radio"><input id="id_beatles_3" name="beatles" type="radio" value="ringo" required></span>
    </label>
</fieldset>
 If you decide not to loop over the radio buttons – e.g., if your template includes {{ myform.beatles }} – they’ll be output in a <div> with <div> tags, as above. The outer <div> container receives the id attribute of the widget, if defined, or BoundField.auto_id otherwise. When looping over the radio buttons, the label and input tags include for and id attributes, respectively. Each radio button has an id_for_label attribute to output the element’s ID.
class RegexField(**kwargs)  
 Default widget: TextInput
 Empty value: Whatever you’ve given as empty_value. Normalizes to: A string. Uses RegexValidator to validate that the given value matches a certain regular expression. Error message keys: required, invalid
  Takes one required argument:  
regex  
A regular expression specified either as a string or a compiled regular expression object. 
 Also takes max_length, min_length, strip, and empty_value which work just as they do for CharField.  
strip  
Defaults to False. If enabled, stripping will be applied before the regex validation.
strip  
Defaults to False. If enabled, stripping will be applied before the regex validation.
class Select  
 
template_name: 'django/forms/widgets/select.html'
 
option_template_name: 'django/forms/widgets/select_option.html'
 Renders as: <select><option ...>...</select>
   
choices  
This attribute is optional when the form field does not have a choices attribute. If it does, it will override anything you set here when the attribute is updated on the Field.
choices  
This attribute is optional when the form field does not have a choices attribute. If it does, it will override anything you set here when the attribute is updated on the Field.
class SelectDateWidget  
 
template_name: 'django/forms/widgets/select_date.html'
  Wrapper around three Select widgets: one each for month, day, and year. Takes several optional arguments:  
years  
An optional list/tuple of years to use in the “year” select box. The default is a list containing the current year and the next 9 years. 
  
months  
An optional dict of months to use in the “months” select box. The keys of the dict correspond to the month number (1-indexed) and the values are the displayed months: MONTHS = {
    1:_('jan'), 2:_('feb'), 3:_('mar'), 4:_('apr'),
    5:_('may'), 6:_('jun'), 7:_('jul'), 8:_('aug'),
    9:_('sep'), 10:_('oct'), 11:_('nov'), 12:_('dec')
}
 
  
empty_label  
If the DateField is not required, SelectDateWidget will have an empty choice at the top of the list (which is --- by default). You can change the text of this label with the empty_label attribute. empty_label can be a string, list, or tuple. When a string is used, all select boxes will each have an empty choice with this label. If empty_label is a list or tuple of 3 string elements, the select boxes will have their own custom label. The labels should be in this order ('year_label', 'month_label', 'day_label'). # A custom empty label with string
field1 = forms.DateField(widget=SelectDateWidget(empty_label="Nothing"))

# A custom empty label with tuple
field1 = forms.DateField(
    widget=SelectDateWidget(
        empty_label=("Choose Year", "Choose Month", "Choose Day"),
    ),
)
empty_label  
If the DateField is not required, SelectDateWidget will have an empty choice at the top of the list (which is --- by default). You can change the text of this label with the empty_label attribute. empty_label can be a string, list, or tuple. When a string is used, all select boxes will each have an empty choice with this label. If empty_label is a list or tuple of 3 string elements, the select boxes will have their own custom label. The labels should be in this order ('year_label', 'month_label', 'day_label'). # A custom empty label with string
field1 = forms.DateField(widget=SelectDateWidget(empty_label="Nothing"))

# A custom empty label with tuple
field1 = forms.DateField(
    widget=SelectDateWidget(
        empty_label=("Choose Year", "Choose Month", "Choose Day"),
    ),
)
months  
An optional dict of months to use in the “months” select box. The keys of the dict correspond to the month number (1-indexed) and the values are the displayed months: MONTHS = {
    1:_('jan'), 2:_('feb'), 3:_('mar'), 4:_('apr'),
    5:_('may'), 6:_('jun'), 7:_('jul'), 8:_('aug'),
    9:_('sep'), 10:_('oct'), 11:_('nov'), 12:_('dec')
}
years  
An optional list/tuple of years to use in the “year” select box. The default is a list containing the current year and the next 9 years.
class SelectMultiple  
 
template_name: 'django/forms/widgets/select.html'
 
option_template_name: 'django/forms/widgets/select_option.html'
  Similar to Select, but allows multiple selection: <select multiple>...</select>
class SlugField(**kwargs)  
 Default widget: TextInput
 Empty value: Whatever you’ve given as empty_value. Normalizes to: A string. Uses validate_slug or validate_unicode_slug to validate that the given value contains only letters, numbers, underscores, and hyphens. Error messages: required, invalid
  This field is intended for use in representing a model SlugField in forms. Takes two optional parameters:  
allow_unicode  
A boolean instructing the field to accept Unicode letters in addition to ASCII letters. Defaults to False. 
  
empty_value  
The value to use to represent “empty”. Defaults to an empty string.
allow_unicode  
A boolean instructing the field to accept Unicode letters in addition to ASCII letters. Defaults to False.
class SplitDateTimeField(**kwargs)  
 Default widget: SplitDateTimeWidget
 Empty value: None
 Normalizes to: A Python datetime.datetime object. Validates that the given value is a datetime.datetime or string formatted in a particular datetime format. Error message keys: required, invalid, invalid_date, invalid_time
  Takes two optional arguments:  
input_date_formats  
A list of formats used to attempt to convert a string to a valid datetime.date object. 
 If no input_date_formats argument is provided, the default input formats for DateField are used.  
input_time_formats  
A list of formats used to attempt to convert a string to a valid datetime.time object. 
 If no input_time_formats argument is provided, the default input formats for TimeField are used.
input_date_formats  
A list of formats used to attempt to convert a string to a valid datetime.date object.
input_time_formats  
A list of formats used to attempt to convert a string to a valid datetime.time object.
class SplitDateTimeWidget  
 
template_name: 'django/forms/widgets/splitdatetime.html'
  Wrapper (using MultiWidget) around two widgets: DateInput for the date, and TimeInput for the time. Must be used with SplitDateTimeField rather than DateTimeField. SplitDateTimeWidget has several optional arguments:  
date_format  
Similar to DateInput.format 
  
time_format  
Similar to TimeInput.format 
  
date_attrs 
  
time_attrs  
Similar to Widget.attrs. A dictionary containing HTML attributes to be set on the rendered DateInput and TimeInput widgets, respectively. If these attributes aren’t set, Widget.attrs is used instead.
time_attrs  
Similar to Widget.attrs. A dictionary containing HTML attributes to be set on the rendered DateInput and TimeInput widgets, respectively. If these attributes aren’t set, Widget.attrs is used instead.
class SplitHiddenDateTimeWidget  
 
template_name: 'django/forms/widgets/splithiddendatetime.html'
  Similar to SplitDateTimeWidget, but uses HiddenInput for both date and time.
class Textarea  
 
template_name: 'django/forms/widgets/textarea.html'
 Renders as: <textarea>...</textarea>
class TextInput  
 
input_type: 'text'
 
template_name: 'django/forms/widgets/text.html'
 Renders as: <input type="text" ...>
class TimeField(**kwargs)  
 Default widget: TimeInput
 Empty value: None
 Normalizes to: A Python datetime.time object. Validates that the given value is either a datetime.time or string formatted in a particular time format. Error message keys: required, invalid
  Takes one optional argument:  
input_formats  
A list of formats used to attempt to convert a string to a valid datetime.time object. 
 If no input_formats argument is provided, the default input formats are taken from TIME_INPUT_FORMATS if USE_L10N is False, or from the active locale format TIME_INPUT_FORMATS key if localization is enabled. See also format localization.
input_formats  
A list of formats used to attempt to convert a string to a valid datetime.time object.