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. 3 Facebook Tips and Tricks Your Local Business Will Benefit

  2. Clean Docker Images

  3. Development Environment for Django in Docker Compose

  4. How Online Reviews Impact Local SEO

  5. 3 Money-Saving Tips For Your Company


News Letter

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