[Answered ]-Django, define field to be hidden in every form

2👍

You can write your own Field, which will use widget with attribute hidden, for example:

class HiddenTextField(models.TextField):
    def formfield(self, **kwargs):
        defaults = {'widget': widgets.Textarea({'hidden': ''})}
        defaults.update(kwargs)
        return super(HiddenTextField, self).formfield(**defaults)

And just replace TextField to HiddenTextField in your model(s)

Leave a comment