Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Quill to edit Django flatpages? #117

Open
bernd-wechner opened this issue May 3, 2023 · 1 comment
Open

Using Quill to edit Django flatpages? #117

bernd-wechner opened this issue May 3, 2023 · 1 comment

Comments

@bernd-wechner
Copy link

The flatpages app is built into Django but lacks a decent editor:

https://docs.djangoproject.com/en/4.2/ref/contrib/flatpages/

I'd love to see some docs on how to attach the Quill editor to the django flatpages admin.

@bernd-wechner
Copy link
Author

It's not hard as it happens, but still would be nice to see it documented as it's a common use case IMHO.

In the app's top directory, just ad admin.py if you don't have one or open it if you have one and add:

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 django_quill.widgets import QuillWidget

class FlatPageCustom(FlatPageAdmin):
    formfield_overrides = {
        models.TextField: {'widget': QuillWidget}
    }

admin.site.unregister(FlatPage)
admin.site.register(FlatPage, FlatPageCustom)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant