About Making All Form Fields Hidden

You can change the fields of a form to hidden fields by overriding the __init__ method and changing the widgets for all fields set at self.fields:

from django import forms
from .models import Project

class ProjectForm(forms.ModelForm):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        for field_name, field in self.fields.items():
            if isinstance(field, (
                forms.ModelMultipleChoiceField,
                forms.MultipleChoiceField,
            )):
                field.widget = forms.MultipleHiddenInput()
            else:
                field.widget = forms.HiddenInput()

    class Meta:
        model = Project
        fields = "__all__"

Tips and Tricks Programming Django 4.2 Django 3.2 Django 2.2