Skip to main content

Django Textarea Widget Integrated Vditor with Customizable Configuration

Project description

dj_vditor

Django-vditor 是基于 vditor v3.8.0 的一个 django Markdown 文本编辑插件应用。

Django-mdeditor 的灵感参考自伟大的项目 django-ckeditor.

Installation

pip install dj-vditor-widget

Quick Start

  1. Add to INSTALLED_APPS:
INSTALLED_APPS = [
    ...
    'dj_vditor',
]
  1. 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'),
]
  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': '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_widget-0.2.1.tar.gz (4.1 MB view details)

Uploaded Source

Built Distribution

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

dj_vditor_widget-0.2.1-py3-none-any.whl (4.2 MB view details)

Uploaded Python 3

File details

Details for the file dj_vditor_widget-0.2.1.tar.gz.

File metadata

  • Download URL: dj_vditor_widget-0.2.1.tar.gz
  • Upload date:
  • Size: 4.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.4

File hashes

Hashes for dj_vditor_widget-0.2.1.tar.gz
Algorithm Hash digest
SHA256 2a50401e9392feb346a942625d8a54c04f56a5273d5d6b33df933fbced1ad71c
MD5 28c4d2d2bb463e24e600cb07be6a5e69
BLAKE2b-256 254b5593b8d836c017619dd66cdd787838992199450ea0cd2e7d64cdd8c4abda

See more details on using hashes here.

File details

Details for the file dj_vditor_widget-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for dj_vditor_widget-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6ca4fb1fbd1991e10266fe7f20af05518ac2d353b64137d5fa041dd60603f82d
MD5 a94d1ca075f2d37f0be1acf292039f7b
BLAKE2b-256 3212e3130e02a7bed923a918930361c1164156a3e338e92eb2640c4765f29916

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