Django Forms

Hidden

To hide a field:

if not settings.show_method:
    self.fields["methods"].widget = forms.HiddenInput()

Label

To change the label:

self.fields["category"].label = "Category"

Required

for name in ("assessor_comments", "result"):
   self.fields[name].required = True

Testing

assert HTTPStatus.FOUND == response.status_code, response.context["form"].errors