Download NicEdit from official website or register NicEdit script into project. Add NicEdit JavaScript file into project's static folder. Create an folder named "js" and place the NicEdit JavaScript file.
Django Admin Configuration:
form.py:
from .modelsimportProduct fromdjangoimportforms classProductForm(forms.ModelForm): classMeta: model=Product# Specify your model fields='__all__'# Or list the fields you want to include # Add a widget to the description field description=forms.CharField(widget=forms.Textarea(attrs={'class': 'nic-edit','cols': 80}))
admin.py:
fromdjango.contribimportadmin from .modelsimport* from .formimportProductForm classProductAdmin(admin.ModelAdmin): list_display= ('name', 'description') list_per_page=10 search_fields=['name','category__name'] form=ProductForm classMedia: js= ('/static/js/nicEdit.js', '/static/js/script.js') admin.site.register(Product, ProductAdmin)