django_sorcery.forms module¶
Helper functions for creating Form classes from SQLAlchemy models.
-
class
django_sorcery.forms.BaseModelForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None, renderer=None, session=None)[source]¶ Bases:
django.forms.models.BaseModelFormBase ModelForm for sqlalchemy models.
-
is_valid(rollback=True)[source]¶ Return True if the form has no errors, or False otherwise.
Will also rollback the session transaction.
-
model_to_dict()[source]¶ Returns a dict containing the data in
instancesuitable for passing as formsinitialkeyword argument.
-
-
class
django_sorcery.forms.ModelForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None, renderer=None, session=None)[source]¶ Bases:
django_sorcery.forms.BaseModelFormModelForm base class for sqlalchemy models.
-
base_fields= {}¶
-
declared_fields= {}¶
-
media¶
-
-
class
django_sorcery.forms.ModelFormMetaclass[source]¶ Bases:
django.forms.forms.DeclarativeFieldsMetaclassModelForm metaclass for sqlalchemy models.
-
class
django_sorcery.forms.SQLAModelFormOptions(options=None)[source]¶ Bases:
django.forms.models.ModelFormOptionsModel form options for sqlalchemy.
-
django_sorcery.forms.apply_limit_choices_to_form_field(formfield)[source]¶ Apply limit_choices_to to the formfield’s query if needed.
-
django_sorcery.forms.fields_for_model(model, session, fields=None, exclude=None, widgets=None, formfield_callback=None, localized_fields=None, labels=None, help_texts=None, error_messages=None, field_classes=None, apply_limit_choices_to=True, **kwargs)[source]¶ Returns a dictionary containing form fields for a given model.
-
django_sorcery.forms.model_to_dict(instance, fields=None, exclude=None)[source]¶ Return a dict containing the data in
instancesuitable for passing as a Form’sinitialkeyword argument.fieldsis an optional list of field names. If provided, return only the named.excludeis an optional list of field names. If provided, exclude the named from the returned dict, even if they are listed in thefieldsargument.