@@ -4,13 +4,18 @@ Django plugin for using [Editor.js](https://editorjs.io/)
4
4
5
5
> This plugin works fine with JSONField in Django >= 3.1
6
6
7
+ [ ![ Python versions] ( https://img.shields.io/pypi/pyversions/django-editorjs-fields )] ( https://pypi.org/project/django-editorjs-fields/ )
8
+ [ ![ Python versions] ( https://img.shields.io/pypi/djversions/django-editorjs-fields )] ( https://pypi.org/project/django-editorjs-fields/ )
9
+ [ ![ Downloads] ( https://pepy.tech/badge/django-editorjs-fields/month )] ( https://pepy.tech/project/django-editorjs-fields/month )
10
+
7
11
## Installation
8
12
9
13
``` bash
10
14
pip install django-editorjs-fields
11
15
```
12
16
13
- Add django_editorjs_fields to INSTALLED_APPS in settings.py for your project:
17
+ Add ` django_editorjs_fields ` to ` INSTALLED_APPS ` in ` settings.py ` for your project:
18
+
14
19
``` python
15
20
# settings.py
16
21
INSTALLED_APPS = [
@@ -22,6 +27,7 @@ INSTALLED_APPS = [
22
27
## Usage
23
28
24
29
Add code in your model
30
+
25
31
``` python
26
32
# models.py
27
33
from django.db import models
@@ -37,10 +43,32 @@ class Post(models.Model):
37
43
38
44
Or add custom Editor.js plugins and configs ([ List plugins] ( https://github.com/editor-js/awesome-editorjs ) )
39
45
46
+ ** django-editorjs-fields** includes this list of Editor.js plugins by default:
47
+
48
+ ``` python
49
+ [
50
+ ' @editorjs/paragraph' ,
51
+ ' @editorjs/image' ,
52
+ ' @editorjs/header' ,
53
+ ' @editorjs/list' ,
54
+ ' @editorjs/checklist' ,
55
+ ' @editorjs/quote' ,
56
+ ' @editorjs/raw' ,
57
+ ' @editorjs/code' ,
58
+ ' @editorjs/inline-code' ,
59
+ ' @editorjs/embed' ,
60
+ ' @editorjs/delimiter' ,
61
+ ' @editorjs/warning' ,
62
+ ' @editorjs/link' ,
63
+ ' @editorjs/marker' ,
64
+ ' @editorjs/table' ,
65
+ ]
66
+ ```
67
+
40
68
``` python
41
69
# models.py
42
70
from django.db import models
43
- from django_editorjs_fields import EditorJsJSONField, EditorJsTextField # import
71
+ from django_editorjs_fields import EditorJsJSONField, EditorJsTextField
44
72
45
73
46
74
class Post (models .Model ):
@@ -70,7 +98,8 @@ class Post(models.Model):
70
98
71
99
```
72
100
73
- If you want to upload images to the editor then add django_editorjs_fields.urls to urls.py for your project:
101
+ If you want to upload images to the editor then add ` django_editorjs_fields.urls ` to ` urls.py ` for your project with ` DEBUG=True ` :
102
+
74
103
``` python
75
104
# urls.py
76
105
from django.contrib import admin
@@ -79,14 +108,40 @@ from django.conf import settings
79
108
from django.conf.urls.static import static
80
109
81
110
urlpatterns = [
82
- path( ' admin/ ' , admin.site.urls),
111
+ ...
83
112
path(' editorjs/' , include(' django_editorjs_fields.urls' )),
113
+ ...
84
114
] + static(settings.MEDIA_URL , document_root = settings.MEDIA_ROOT )
85
115
```
86
116
117
+ In production ` DEBUG=False ` (use nginx to display images):
118
+
119
+ ``` python
120
+ # urls.py
121
+ from django.contrib import admin
122
+ from django.urls import path, include
123
+
124
+ urlpatterns = [
125
+ ...
126
+ path(' editorjs/' , include(' django_editorjs_fields.urls' )),
127
+ ...
128
+ ]
129
+ ```
130
+
87
131
See an example of how you can work with the plugin [ here] ( https://github.com/2ik/django-editorjs-fields/blob/main/example )
88
132
133
+ ## Configure
134
+
135
+ The application can be configured by editing the project's ` settings.py `
136
+ file.
137
+
138
+ | Key | Description | Default |
139
+ | ------------------------------ | ------------------------------------------------------------------------------- | ------------------------------------------------------ |
140
+ | ` EDITORJS_IMAGE_UPLOAD_PATH ` | Path uploads images | ` settings.MEDIA_URL + 'uploads/images/' ` |
141
+ | ` EDITORJS_IMAGE_NAME_ORIGINAL ` | To use the original name of the image file? | ` False ` |
142
+ | ` EDITORJS_IMAGE_NAME_POSTFIX ` | Image file name postfix. Ignored when ` EDITORJS_IMAGE_NAME_ORIGINAL ` is ` True ` | ` token_urlsafe(5) # from secrets import token_urlsafe ` |
143
+ | ` EDITORJS_IMAGE_NAME ` | Image file name postfix. Ignored when ` EDITORJS_IMAGE_NAME_ORIGINAL ` is ` False ` | ` token_urlsafe(8) # from secrets import token_urlsafe ` |
89
144
90
145
## Support and updates
91
146
92
- Use github issues https://github.com/2ik/django-editorjs-fields/issues
147
+ Use github issues https://github.com/2ik/django-editorjs-fields/issues
0 commit comments