Django vditor integration
Project description
dj_vditor
Django-vditor 是基于 vditor v3.8.0 的一个 django Markdown 文本编辑插件应用。
Django-mdeditor 的灵感参考自伟大的项目 django-ckeditor.
Installation
pip install dj_vditor
# 如果需要OSS支持
pip install dj_vditor[oss]
Quick Start
- Add to
INSTALLED_APPS:
INSTALLED_APPS = [
...
'dj_vditor',
]
- Add URL route in
urls.py:
# 当然你也可以自定义url和view, 只要跟配置中的upload.url一致即可
from dj_vditor.views import vditor_images_upload_view
urlpatterns = [
...
path('upload-to-oss/', vditor_images_upload_view, name='vditor_upload'),
]
- Use in Model:
from dj_vditor.models import VditorTextField
class Article(models.Model):
content = VditorTextField()
- Configure settings:
# settings.py
# 如果你需要使用OSS上传, 请设置以下配置
DJ_IMAGE_UPLOADER_OSS_CONFIG = {
'ACCESS_KEY_ID': 'your_aliyun_key',
'ACCESS_KEY_SECRET': 'your_aliyun_secret',
'ENDPOINT': 'oss-cn-beijing.aliyuncs.com',
'BUCKET_NAME': 'your-bucket-name',
'BASE_PATH': 'your-pathname' # 定义你的上传路径, 可选
}
# 这是默认配置, 如果不需要修改的话, 可以不设置, 直接使用默认配置
VDITOR_CONFIGS = {
"width": "100%",
"height": 720,
"cache": {"enable": False},
"mode": "sv",
"debugger": "false",
"icon": "ant",
"outline": "",
"counter": {
"enable": True,
},
"lang": "zh_CN",
"toolbar": [
"emoji",
"headings",
"bold",
"italic",
"strike",
"link",
"|",
"list",
"ordered-list",
"check",
"outdent",
"indent",
"|",
"quote",
"line",
"code",
"inline-code",
"insert-after",
"table",
"|",
"upload",
"fullscreen",
"export",
"|",
"outline",
],
"upload": {
"url": "/upload-to-oss/", # 上传接口地址
"max": 5 * 1024 * 1024, # 5MB
"accept": "image/png,image/jpeg,image/gif,image/webp", # 允许类型
"fieldName": "file[]",
"multiple": True,
},
}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
dj_vditor-0.1.6.tar.gz
(2.9 MB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dj_vditor-0.1.6.tar.gz.
File metadata
- Download URL: dj_vditor-0.1.6.tar.gz
- Upload date:
- Size: 2.9 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8fec0b2b6139c280d35307ce1052880e89c44a1115cdd5b763c15d0a2a4d7f9c
|
|
| MD5 |
644d54f7493395b2ad5391a1000a5414
|
|
| BLAKE2b-256 |
e5878cb700e9bee692c60ba7f4425b1ae145f027b015432f1e6c138709fb72ba
|
File details
Details for the file dj_vditor-0.1.6-py3-none-any.whl.
File metadata
- Download URL: dj_vditor-0.1.6-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d016ffb0d42282b724642addc3ac3f92f1ed9273c09859d9aba565a7fe7d0cd1
|
|
| MD5 |
19dc0c39af2a6804335b45d4405a49d5
|
|
| BLAKE2b-256 |
8af6d54cc666176b7bb7156b80094a7672bc5245a90b4d562490101c3a7c8ac7
|