To integrate NicEdit in django Admin:
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 .models import Product
from django import forms
class ProductForm(forms.ModelForm):
class Meta:
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:
from django.contrib import admin
from .models import *
from .form import ProductForm
class ProductAdmin(admin.ModelAdmin):
list_display = ('name', 'description')
list_per_page=10
search_fields=['name','category__name']
form = ProductForm
class Media:
js = ('/static/js/nicEdit.js', '/static/js/script.js')
admin.site.register(Product, ProductAdmin)
script.js:
document.addEventListener("DOMContentLoaded", function() {
var textAreas = document.getElementsByClassName("nic-edit");
for (var i = 0; i < textAreas.length; i++) {
new nicEditor({ fullPanel: true }).panelInstance(textAreas[i]);
}
});

VIDEO GUIDE:
Post your comments / questions
Recent Article
- How to get domain name information from a Domain using Python
- ModulenotFoundError: no module named 'debug_toolbar' -SOLUTION
- How to create superuser in django project hosted in cPanel without terminal
- CSS & images not loading in django admin | cpanel without terminal
- Could not build wheels for mysqlclient, which is required to install pyproject.toml-based projects
- How to sell domain name on Godaddy (2023)
- TemplateSyntaxError at / Could not parse the remainder: ' + 1' from 'forloop.counter0 + 1'
- urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'OpenSSL 1.0
Related Article