Managing course modules and their contents
You are going to build a system to manage course modules and their contents. You will need to build forms that can be used for managing multiple modules per course and different types of content for each module. Both modules and their contents will have to follow a specific order and you should be able to reorder them using the CMS.
Using formsets for course modules
Django comes with an abstraction layer to work with multiple forms on the same page. These groups of forms are known as formsets. Formsets manage multiple instances of a certain Form
or ModelForm
. All forms are submitted at once and the formset takes care of the initial number of forms to display, limiting the maximum number of forms that can be submitted and validating all the forms.
Formsets include an is_valid()
method to validate all forms at once. You can also provide initial data for the forms and specify how many additional empty forms to display. You can learn...