Often, to manage content efficiently we use WYSIWYG (What You See Is What You Get) editor which stores our content in html and is also helpful to upload images, creating links, lists and works almost like WordPress editor. This article is in continuation of Blog CMS Project in Django. Check this out here – Building Blog CMS (Content Management System) with Django
How to add WYSIWYG (What You See Is What You Get) editor to Django Project?
1. Install summernote –
# installing wysiwyg editor pip3 install django-summernote
2. Add the editor to installed apps in the settings file
3. Migrate the project
# migrate django summernote python3 manage.py migrate
4.Customize admin interface –
Now we will customize the admin interface for the app. For that open the admin.py file and add the below code
5. Adding media setting for our editor
Open your python settings file and add these lines
The editor works well in production but for the development server it won’t work because of the way the static files load so to make that work we need to add a condition in django projects urls.py
6. Customizing Admin Page –
Django also gives the option to customize Admin page, we will do an minimal customization of changing the name from django default to GeeksForGeeks. go to urls.py file in django project and add these lines
Now run the server and login into admin panel using the superuser credentials. You will see something like in the below picture. So we have created and customized admin class for creating, managing and listing posts for our CMS with custom admin login.
7. Output Screenshots –
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. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course