22👍
✅
I think this section in the documentation should be useful to solve the problem.
from django.forms import ModelForm, Textarea
class PostModelForm(ModelForm):
class Meta:
model = Post
widgets = {
'content': Textarea(attrs={'cols': 80, 'rows': 20}),
}
11👍
Alternative to jcollardo’s solution (same result, different syntax):
from django import forms
class PostModelForm(forms.ModelForm):
content = forms.CharField(widget=forms.Textarea)
class Meta:
model = Post
👤Tom
- Django's "dumpdata" or Postgres' "pg_dump"?
- Django ajax post 403 forbidden
- How to prevent user to access login page in django when already logged in?
1👍
You are using models not forms, which means you can’t use textarea properly. Instead you can try TextField:
field_name = models.TextField( **options)
Source:stackexchange.com