Control the size TextArea widget look in django admin Control the size TextArea widget look in django admin python python

Control the size TextArea widget look in django admin


This is a browser-specific problem.

According to the thread Height of textarea does not match the rows in Firefox:

Firefox always adds an extra line after the textfield. If you want it to have a constant height, use CSS ...

You can set a style attribute of the textarea:

from django.db import modelsfrom django.forms import Textareaclass RulesAdmin(admin.ModelAdmin):    formfield_overrides = {        models.TextField: {'widget': Textarea(                           attrs={'rows': 1,                                  'cols': 40,                                  'style': 'height: 1em;'})},    }

Works for me - tested on Firefox v. 23 and Chrome v. 29.

Hope that helps.