Skip to main content

No project description provided

Project description

dj_vditor

Django integration for Vditor Markdown Editor

Installation

pip install dj_vditor

# 如果需要OSS支持
pip install dj_vditor[oss]

Quick Start

  1. Add to INSTALLED_APPS:
INSTALLED_APPS = [
    ...
    'dj_vditor',
]
  1. Add URL route in urls.py:
# 当然你也可以自定义url和view, 只要跟配置中的upload.url一致即可
urlpatterns = [
    ...
    path('vditor/', include('dj_vditor.urls')),
]
  1. Use in Model:
from dj_vditor.models import VditorTextField

class Article(models.Model):
    content = VditorTextField()
  1. 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': 'user-uploads/'  # 定义你的上传路径, 可选
}
# 这是默认配置, 如果不需要修改的话, 可以不设置, 直接使用默认配置
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": "/vditor/upload/",  # 上传接口地址
        "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.2.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dj_vditor-0.1.2-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file dj_vditor-0.1.2.tar.gz.

File metadata

  • Download URL: dj_vditor-0.1.2.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.4

File hashes

Hashes for dj_vditor-0.1.2.tar.gz
Algorithm Hash digest
SHA256 56453b3d5e55080cfa527659d1f0a667a2e01382201fb0fab3edd13c55d972fd
MD5 5d8d65c6c6059af0e751a53a93f297ea
BLAKE2b-256 de8ce3b38177b3d97db055cac757244f105d790395c2bab799127bbc54b507ff

See more details on using hashes here.

File details

Details for the file dj_vditor-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: dj_vditor-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 3.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.4

File hashes

Hashes for dj_vditor-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bce7be5db9be06534d9dc94897235de21a8d6b4f618dbaa90f45109743e81188
MD5 0fdbe21f95aaaf048b6ea9ffcd87772b
BLAKE2b-256 8d06c62db034839568f92e50e604d9816ba1430d375b543889505824c7f9cba9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page