[Answered ]-Is any way to create hidden form field in CreateView form?

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
    ...

Leave a comment