TinyMCE is a online rich text editor which is fully flexible and provides customisation. mostly used to get dynamic data such as articles in GFG and much more, their is no static database for posts
Installation –
To integrate it with Django web app or website you need to first install its pip library
pip install django-tinymce
Integrate with Django Project –
add tinyMCE as individual app in setting.py
INSTALLED_APPS = [
...
'tinymce',
...
]
Also add default configuration for tinyMCE editor in settings.py
TINYMCE_DEFAULT_CONFIG = {
'cleanup_on_startup': True,
'custom_undo_redo_levels': 20,
'selector': 'textarea',
'theme': 'silver',
'plugins': '''
textcolor save link image media preview codesample contextmenu
table code lists fullscreen insertdatetime nonbreaking
contextmenu directionality searchreplace wordcount visualblocks
visualchars code fullscreen autolink lists charmap print hr
anchor pagebreak
''',
'toolbar1': '''
fullscreen preview bold italic underline | fontselect,
fontsizeselect | forecolor backcolor | alignleft alignright |
aligncenter alignjustify | indent outdent | bullist numlist table |
| link image media | codesample |
''',
'toolbar2': '''
visualblocks visualchars |
charmap hr pagebreak nonbreaking anchor | code |
''',
'contextmenu': 'formats | link image',
'menubar': True,
'statusbar': True,
}
here in configuration dictionary you can customise editor by changing values like theme and many more.
setting TinyMCE is done now to bring it into actions we need forms.py file with some required values like needed size of input field it is used by displaying content on html page
from django import forms from tinymce import TinyMCE from .models import _your_model_ class TinyMCEWidget(TinyMCE): def use_required_attribute(self, *args): return False class PostForm(forms.ModelForm): content = forms.CharField( widget=TinyMCEWidget( attrs={'required': False, 'cols': 30, 'rows': 10} ) ) class Meta: model = _your_model_ fields = '__all__' |
Last step is to add htmlfield to your model you can also use different field check out them on their official website
... from tinymce.models import HTMLField class article(models.Model): ... content = HTMLField() |
And its all set just make migrations for see changes in admin page by running following commands
python manage.py makemigrations
python manage.py migrate
Now check it in admin area by running server
python manage.py runserver
Output –
here how it will look like it may have different appearance

Editor in admin area
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
Recommended Posts:
- Connect Django Project to MongoDB using Django
- Styling Django Forms with django-crispy-forms
- Adding Tags Using Django-Taggit in Django Project
- Handling Ajax request in Django
- Django Introduction | Set 2 (Creating a Project)
- now - Django Template Tags
- Python | User groups with Custom permissions in Django
- Python | Django Admin Interface
- Python | Django-allauth setup and Configuration
- Python Django | Google authentication and Fetching mails from scratch
- Python | Uploading images in Django
- Add the slug field inside Django Model
- Intermediate fields in Django | Python
- Django - Dealing with warnings
- Django - Creating Apps | Set - 1
- Django - Creating apps | Set - 2
- Views In Django | Python
- Python | Sessions framework using django
- Django Models | Set - 1
- Django Models | Set - 2
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

