Skip to content

Commit 9cdd61a

Browse files
committed
Update Readme
1 parent c20b487 commit 9cdd61a

File tree

1 file changed

+60
-5
lines changed

1 file changed

+60
-5
lines changed

README.md

Lines changed: 60 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@ Django plugin for using [Editor.js](https://editorjs.io/)
44

55
> This plugin works fine with JSONField in Django >= 3.1
66
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+
711
## Installation
812

913
```bash
1014
pip install django-editorjs-fields
1115
```
1216

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+
1419
```python
1520
# settings.py
1621
INSTALLED_APPS = [
@@ -22,6 +27,7 @@ INSTALLED_APPS = [
2227
## Usage
2328

2429
Add code in your model
30+
2531
```python
2632
# models.py
2733
from django.db import models
@@ -37,10 +43,32 @@ class Post(models.Model):
3743

3844
Or add custom Editor.js plugins and configs ([List plugins](https://github.com/editor-js/awesome-editorjs))
3945

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+
4068
```python
4169
# models.py
4270
from django.db import models
43-
from django_editorjs_fields import EditorJsJSONField, EditorJsTextField # import
71+
from django_editorjs_fields import EditorJsJSONField, EditorJsTextField
4472

4573

4674
class Post(models.Model):
@@ -70,7 +98,8 @@ class Post(models.Model):
7098

7199
```
72100

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+
74103
```python
75104
# urls.py
76105
from django.contrib import admin
@@ -79,14 +108,40 @@ from django.conf import settings
79108
from django.conf.urls.static import static
80109

81110
urlpatterns = [
82-
path('admin/', admin.site.urls),
111+
...
83112
path('editorjs/', include('django_editorjs_fields.urls')),
113+
...
84114
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
85115
```
86116

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+
87131
See an example of how you can work with the plugin [here](https://github.com/2ik/django-editorjs-fields/blob/main/example)
88132

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` |
89144

90145
## Support and updates
91146

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

Comments
 (0)