This is an early prototyp and work in progress
Install with Pip:
pip install django-editorjs-field
INSTALLED_APPS = [
...
'editorjs_field',
...
]
from django.db import models
from editorjs_field.fields import EditorJSField
class Article(models.Model):
title = models.CharField(max_length=100)
content = EditorJSField()
from django.contrib import admin
from .models import Article
class ArticleAdmin(admin.ModelAdmin):
list_display = ('title',)
admin.site.register(Article, ArticleAdmin)
from django import forms
from editorjs_field.widgets import EditorJsWidget
class ArticleEditorForm(forms.Form):
title = forms.CharField(label='Title')
document = forms.CharField(label='Document', widget=EditorJsWidget)
An example can be found in the example folder. To run them clone the repository and run:
$ cd django-editorjs-field
$ pipenv install
$ pipenv shell
$ cd example
$ python manage.py migrate
$ python manage.py createsuperuser
$ python manage.py runserver
Visit http://localhost:8000/admin
to view the admin widget and
http://localhost:8000/
to view the custom form widget.