Skip to content

Forms


Forms are used within Centurion ERP as the method to display the data from the database. Along with that they are designed to sanitise the user entered data.

Requirements

All forms must meet the following requirements:

  • is defined as a class

  • inherits from core.forms.common.CommonModelForm

  • contains a Meta sub-class with following parameters:

    • fields

    • model

  • Any additional filtering is done as part of an __init__ method that also calls the super-class __init__ first

    • Any filtering of a fields queryset is to filter the existing queryset not redefine it. i.e. field[<field name>].queryset = field[<field name>].queryset.filter()
  • validating fields where the validation requires access to multiple fields is done inside the form class using function clean

    def clean(self):
    
        cleaned_data = super().clean()
    
        # begin example
        responsible_user = cleaned_data.get("responsible_user")
        responsible_teams = cleaned_data.get("responsible_teams") example
    
    
        if not responsible_user and not responsible_teams:
    
            raise ValidationError('A Responsible User or Team must be assigned.')
        # end example
    
        # your validation after `super()` call
    
        return cleaned_data
    

Details Form

A details form is for the display of a models data. This form should inherit from a base form and contain any additional fields as is required for the display of the models data. Additional requirements are as follows:

  • tab is defined as a dict within the class. See Template.

  • There is an __init__ class defined that sets up the additional fields.

    Requirement

    Ensure that there is a call to the super-class __init__ method so that the form is correctly initialised. i.e. super().__init__(*args, **kwargs)

Abstract Classes

The following abstract classes exist for a forms inheritance:

About:

This page forms part of our Project Centurion ERP.

Page Metadata
Version: ToDo: place files short git commit here
Date Created: 2024-07-14
Date Edited: 2024-08-31

Contribution:

Would You like to contribute to our Centurion ERP project? You can assist in the following ways:

 

ToDo: Add the page list of contributors