MaistrenkoAnton / django-material-admin

Material design for django administration
MIT License
324 stars 65 forks source link

TyniMCE didn't work. How the best Django rich text editor to use with Material-Admin? #177

Open Paulo-AndradeDev opened 1 year ago

Paulo-AndradeDev commented 1 year ago

Hi there!

I need to replace textarea with rich text editor in Django Admin.

I tryed out the TyniMCE lib.

However the TyniMCE rich text editor do not work when I use the "material.admin" app. The Django admin only display the text editor if I unregister the "material.admin" app. I figured out that they are “incompatible with each other. I guess, the Django-material-admin overrides the tyniMCE's CSS/Js.

How to solve that problem or
which are the best Django rich text editor to use while use Material-Admin (material.admin" app) as well? Or

Thanks in advance.

SumitSingh-sng commented 8 months ago

You can use the javascript version of TinyMCE and embed it in your project.

xFrann commented 2 months ago

in the admin.py file please add a form overide and use the model provided by tinyMCE

@admin.register(Post)
class PostAdmin(ModelAdmin):
    list_display = ('title', 'slug', 'publish', 'created')
    list_filter = ('created', 'publish')
    search_fields = ('title', 'content')
    prepopulated_fields = {'slug': ('title',)}
    date_hierarchy = 'publish'
    ordering = ('-publish',)

    formfield_overrides = {
        tinymce.models.HTMLField: {'widget': TinyMCE(attrs={'cols': 80, 'rows': 30})},
    }