Search code examples
htmldjangodjango-widget

How to disable resize textarea in django?


I'm trying to disable resize to the textarea widget in django, this is my form:

class VForm(forms.ModelForm):
    class Meta:
        model = Visions
        widgets = {'vision': forms.Textarea(attrs={'rows':6,
                                                   'cols':22,
                                                   'resize':'none'}),
        }

Adding the resize property to none isn't working


Solution

  • The simplest way to do this is to add a style attribute:

     widgets = {'vision': forms.Textarea(attrs={'rows':6,
                                                'cols':22,
                                                'style':'resize:none;'}),
        }