2👍
✅
Define a model form class that includes the hidden input.
class CommentForm(ModelForm):
class Meta:
model = Comment
fields = ('author_name', 'text', 'parent')
widgets = {
'parent': forms.HiddenInput,
}
Then use that form in your view using the form_class
attribute.
class CommentAdd(AjaxableResponseMixin, CreateView):
form_class = CommentForm
...
Source:stackexchange.com