Here are the examples of the python api django.forms.BaseForm taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
3 Examples
0
Source : forms.py
with MIT License
from silviogutierrez
with MIT License
from silviogutierrez
def get_form_from_form_set_or_form(
context_data: Dict[
str, Union[django_forms.BaseForm, django_forms.formsets.BaseFormSet, object]
],
descriptor: FormOrFormSetDescriptor,
) -> Optional[django_forms.BaseForm]:
for key, item in context_data.items():
if isinstance(item, django_forms.BaseForm) and item.prefix == descriptor.prefix:
return item
elif (
isinstance(item, django_forms.formsets.BaseFormSet)
and item.prefix == descriptor.prefix
):
return cast(django_forms.BaseForm, item.empty_form)
return None
def autocomplete(view_func: T) -> T:
0
Source : templates.py
with MIT License
from silviogutierrez
with MIT License
from silviogutierrez
def extract_forms_form_sets_and_actions(interface: Any) -> Extracted:
context = interface._asdict()
context_forms = {}
context_form_sets = {}
context_actions = {}
for name, item in context.items():
if isinstance(item, forms.BaseForm):
context_forms[name] = item
elif isinstance(item, forms.BaseFormSet):
context_form_sets[name] = item
elif isinstance(item, Action):
context_actions[name] = item
elif getattr(item, "is_reactivated_interface", None) is True:
children = extract_forms_form_sets_and_actions(item)
context_forms.update(children.context_forms)
context_form_sets.update(children.context_form_sets)
context_actions.update(children.context_actions)
return Extracted(
context_forms=context_forms,
context_form_sets=context_form_sets,
context_actions=context_actions,
)
def interface(cls: T) -> T:
0
Source : classes.py
with Apache License 2.0
from timoludwig
with Apache License 2.0
from timoludwig
def improve_class_docstring(app, cls, lines):
"""
Improve the documentation of a class if it's a Django model or form
:param app: The Sphinx application object
:type app: ~sphinx.application.Sphinx
:param cls: The instance of the class to document
:type cls: object
:param lines: The docstring lines
:type lines: list [ str ]
"""
if issubclass(cls, models.Model):
improve_model_docstring(app, cls, lines)
elif issubclass(cls, forms.BaseForm):
improve_form_docstring(cls, lines)
def improve_model_docstring(app, model, lines):