1๐
โ
I did something different, and I was missing the โfieldsโ property in meta Class, following the new code, tested and running:
from django.contrib.flatpages.admin import FlatpageForm, FlatPageAdmin
from django.contrib import admin
from django import forms
from django.contrib.flatpages.models import FlatPage
from tinymce.widgets import TinyMCE
class FlatPageForm(forms.ModelForm):
content = forms.CharField(widget=TinyMCE(attrs={'cols': 80, 'rows': 30}))
class Meta:
model = FlatPage
fields = '__all__'
class PageAdmin(FlatPageAdmin):
"""
Page Admin
"""
form = FlatPageForm
admin.site.unregister(FlatPage)
admin.site.register(FlatPage, PageAdmin)
๐คLara
1๐
The accepted answer wasnโt working for me (Django 1.10) so this is what worked for me.
-
I first created a new app called content in my project to keep organized.
manage.py startapp content
-
I added this to my admin.py
from django.contrib import admin from django.contrib.flatpages.admin import FlatPageAdmin from django.contrib.flatpages.models import FlatPage from django.db import models from tinymce.widgets import TinyMCE # Register your models here. class PageAdmin(FlatPageAdmin): """ Page Admin """ formfield_overrides = { models.TextField: {'widget': TinyMCE(attrs={'cols': 100, 'rows': 15})}, } admin.site.unregister(FlatPage) admin.site.register(FlatPage, PageAdmin)
-
Finally run
manage.py collectstatic
, restart your webserver and refresh.
๐คBrett
Source:stackexchange.com