Text Area Widget in Django Admin

Adding widgets to CharField/fields in Django Administrator


If you use django admin to manage your application and use a CharField with size more than 300 i'm sure you need a Text Area to fill it in, yes in your admin too.

It's just a few additional lines to your forms.py (define a new form with widget) and admin.py ( Inform model admin to use the form).

 # forms.py
class FaqForm(forms.ModelForm):
  answer = forms.CharField( widget=forms.Textarea(attrs={'rows': 5, 'cols': 100}))
  class Meta:
    model = Faq
    fields = ('__all__')

That my custom form with Textarea widget attached to answers field which is a CharFIeld.

class FaqsAdmin(admin.ModelAdmin):
  list_display = ['id', 'question', 'status']
  form = FaqForm

You got yourself a text area in your admin.


Wow ! you have someting to tell us. That's great! Please keep in mind that comments are moderated, we employ rel="nofollow" for links, avoid using a spammy word or a domain in name field, it might end up as a Spam. Thanks for reading.

Last 5 Articles

All Articles >

  1. Mitigating Risks In Custom Software Development

  2. Container Security to Secure Microservices

  3. Strategic Messaging

  4. URL Shortener in Django

  5. MySQL as Database Option


News Letter

Subscribe to our email newsletter for useful tips and valuable resources, sent out every new article release.