Django plugin for using Editor.js
Project description
Editor.js for Django
Django plugin for using Editor.js
This plugin works fine with JSONField in Django >= 3.1
Installation
pip install django-editorjs-fields
Add django_editorjs_fields to INSTALLED_APPS in settings.py for your project:
# settings.py
INSTALLED_APPS = [
...
'django_editorjs_fields',
]
Usage
Add code in your model
# models.py
from django.db import models
from django_editorjs_fields import EditorJsJSONField, EditorJsTextField # import
class Post(models.Model):
body_default = models.TextField()
body_editorjs = EditorJsJSONField() # Django >= 3.1
body_editorjs_text = EditorJsTextField() # Django <= 3.0
Or add custom Editor.js plugins and configs (List plugins)
# models.py
from django.db import models
from django_editorjs_fields import EditorJsJSONField, EditorJsTextField # import
class Post(models.Model):
body_custom = EditorJsJSONField(
plugins=[
"@editorjs/image",
"@editorjs/header",
"editorjs-github-gist-plugin",
"@editorjs/code@2.6.0", # version allowed :)
"@editorjs/list@latest",
"@editorjs/inline-code",
"@editorjs/table",
],
tools={
"Image": {
"config": {
"endpoints": {
# Your custom backend file uploader endpoint
"byFile": "/editorjs/image_upload/"
}
}
}
},
null=True,
blank=True
)
If you want to upload images to the editor then add django_editorjs_fields.urls to urls.py for your project:
# urls.py
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
path('admin/', admin.site.urls),
path('editorjs/', include('django_editorjs_fields.urls')),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
See an example of how you can work with the plugin here
Support and updates
Use github issues https://github.com/2ik/django-editorjs-fields/issues
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for django-editorjs-fields-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 903cbab5bef24f993ee3f4dd1e8a3cc56ecbb158eb52fec48141a14555a05579 |
|
MD5 | d1e5ae25066c94b1b4f7dc247870c412 |
|
BLAKE2b-256 | 074cfb4417027d05937ac6c33fd01764c5e6e6d09060153bc5743c39e4c8e826 |
Close
Hashes for django_editorjs_fields-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 610662ee798779c7eb139fc2c2584c543a2643badab49f0f7d846838626c3959 |
|
MD5 | cd8fe8bd414efbf3dec6c7c4836ef549 |
|
BLAKE2b-256 | f3e78327977c76dfabe9ea8a65358a94279d7602a3aed171a53924600708a3e7 |