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. Facebook Business Page Tips

  2. Unit Testing in Python using assertAlmostEqual

  3. 3 Facebook Tips and Tricks Your Local Business Will Benefit

  4. Clean Docker Images

  5. Development Environment for Django in Docker Compose


News Letter

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