disbi.forms module

Forms used throughout the DISBi app.


Construct a form for directly selecting model instances.

Parameters:model (models.Model) – A Django model, for which the form is constructed.
disbi.forms.construct_foreign_select_field(model, field)[source]

Construct a form for directly selecting related model instances.

  • model (models.Model) – A Django model, for which the form is constructed.
  • field (fields.related.ForeignKey) – The field of the realated instances.

Wrapper for construct_modelfieldsform with appropriate arguments.

disbi.forms.construct_modelfieldsform(model, exclude=['id'], direct_select=False)[source]

Construct forms based on a model and available values in the DB.


model (models.Model) – A Django model, for which the forms are constructed.

Keyword Arguments:
  • exclude (iterable) – Fields for which no forms should be constructed.
  • direct_select (bool) – Determines whether a form for directly selecting model instances is constructed.

list – A list of namedtuples with the form classes and the prefix.


Create a form with two fields for selecting experiments.

The fields are select widgets allowing to calculate a fold change between the two.

Parameters:experiments (Queryset) – The selectable experiments.
Returns:Form – The constructed form.
disbi.forms.make_ChoiceField(model, attribute, label=None, empty_choice=None)[source]

Return a ChoiceField and the maxiumn number of choices.

The ChoiceField contains all distinct values of an attribute of model. Addtionally a NULL option is inserted as first choice.

  • model (Model) – The model from which the field should be constructed.
  • attribute (Field) – The attribute of the model.
  • label (str) – The label used when displaying the form (default None).
  • empty_choice (tuple) – 2-tuple of a value label pair, used for enabling the user to choose an empty condition, e.g. no stress.

ChoiceField – A Choicefield based on the available options in the DB. int: The number of availablbe options.


IndexError – Raises error when no entries are found in the DB.