Easily use Quill.js in your django admin.
This project forked from django-quill.
Requires django 2.1.5
-
Install the package from pypi
pip install django-quilljs
-
Add "quilljs" to your INSTALLED_APPS setting like this:
INSTALLED_APPS = ( ... 'quilljs', )
from django.db import models
from quilljs.fields import RichTextField
class MyModel(models.Model):
content = RichTextField()
content2 = RichTextField(config='basic')
If you want to support image uploads, your admin needs to extend from quilljs.admin.QuillAdmin
:
from quilljs.admin import QuillAdmin
class MyAdmin(QuilljsAdmin):
pass
If you don't want to touch your models and enable the editor for all text fields in the admin page, you can do as well:
from quilljs.widgets import QuillEditorWidget
from quilljs.admin import QuillAdmin
class MyAdmin(admin.ModelAdmin):
formfield_overrides = {
models.TextField: {'widget': QuillEditorWidget},
}
To customize this app, extend apps.QuilljsConfig
and modify whatever you need. For example, to add a new toolbar:
from quill.apps import QuilljsConfig
class MyQuilljsConfig(QuilljsConfig):
my_toolbar = dict(full, toolbar_template='quill/toolbars/my_toolbar.html')
To customize the extensions of the images that can be uploaded:
from quill.apps import QuilljsConfig
class MyQuilljsConfig(QuilljsConfig):
allowed_image_extensions = ['jpeg', 'gif']
If you need to call other methods or perform additional actions on the quill editors, they will be available in window.DjangoQuillEditors
.
There are two toolbars that come with this package:
- Full (default): Provides basic font style and size selection, bold, italics, underline, strikethrough, text color, background color, lists, links, and images.
- Basic: Provides bold, italic, underline, lists, and links.
There are several dependencies on npm that are required before building django-quilljs:
$ npm install
$ make watch
$ make test
$ make build
- Better documentation.
- More tests.
- Better support for using outside of the admin.