Skip to content

Instantly share code, notes, and snippets.

@seanmavley
Created June 16, 2015 22:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seanmavley/0a9625425ecdfc620415 to your computer and use it in GitHub Desktop.
Save seanmavley/0a9625425ecdfc620415 to your computer and use it in GitHub Desktop.
Add RichTextField from ckeditor to your FlatPages
# Note: we are renaming the original Admin and Form as we import them!
from django.contrib.flatpages.admin import FlatPageAdmin as FlatPageAdminOld
from django.contrib.flatpages.admin import FlatpageForm as FlatpageFormOld
from django import forms
from ckeditor.widgets import CKEditorWidget
class FlatpageForm(FlatpageFormOld):
content = forms.CharField(widget=CKEditorWidget())
class Meta:
# this is not automatically inherited from FlatpageFormOld
model = FlatPage
fields = ['id', 'title', 'content']
class FlatPageAdmin(FlatPageAdminOld):
form = FlatpageForm
admin.site.unregister(FlatPage)
admin.site.register(FlatPage, FlatPageAdmin)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment