Skip to main content

A Django app to use wangeditor.

Project description

1.Install or add django-wangeditor to your python path.:

pip install django-wangeditor

2.Add “wangeditor” to your INSTALLED_APPS setting like this:

INSTALLED_APPS = [
    ...
    'wangeditor',
]

3.Run the collectstatic management command: $ ./manage.py collectstatic. This will copy static CKEditor required media resources into the directory given by the STATIC_ROOT setting. See Django’s documentation on managing static files for more info.

Usage

Field

The quickest way to add rich text editing capabilities to your models is to use the included RichTextField model field type. For example:

from django.db import models
from wangeditor.fields import WangRichTextField

class Post(models.Model):
    content = WangRichTextField()

Use upload local pictures

1.Add a WANGEDITOR_UPLOAD_PATH setting to the project’s settings.py file. This setting specifies a relative path to your wangeditor media upload directory. CKEditor uses Django’s storage API. By default, Django uses the file system storage backend (it will use your MEDIA_ROOT and MEDIA_URL):

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

WANGEDITOR_UPLOAD_PATH = "uploads/"

2.Include the wangeditor URLconf in your project urls.py like this:

from django.conf.urls.static import static
from django.conf import settings
# django >= 2.0
path('wangeditor/', include('wangeditor.urls'))
# django < 2.0
url(r'wangeditor/', include('wangeditor.urls'))
if settings.DEBUG:
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

config

Optional - customizing wangEditor editor Add a WANGEDITOR_CONFIGS setting to the project’s settings.py file.:

WANGEDITOR_CONFIGS = {
 "default": {
   "toolbar_config":{
     "modalAppendToBody": False,
   }
   "menu_conf": {
      "uploadImage": {
         "server": "/wangeditor/img_upload/",
       },
       "uploadVideo": {
         "server": "/wangeditor/video_upload/"
       }
   }
}
# toobar_config and menu_conf cong please see https://www.wangeditor.com/v5/toolbar-config.html and https://www.wangeditor.com/v5/menu-config.html

Update Log

version-2.0.0

1、update wangeditor to wangeditor-v5;

version-1.0.2

1、Resolve compatibility issues with django 4.0

Refer to the configuration for more information, please see https://www.kancloud.cn/wangfupeng/wangeditor3/332599

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

django-wangeditor-2.0.0.tar.gz (1.1 MB view details)

Uploaded Source

Built Distribution

django_wangeditor-2.0.0-py3-none-any.whl (1.1 MB view details)

Uploaded Python 3

File details

Details for the file django-wangeditor-2.0.0.tar.gz.

File metadata

  • Download URL: django-wangeditor-2.0.0.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for django-wangeditor-2.0.0.tar.gz
Algorithm Hash digest
SHA256 be4f7eba7d437a04212aff6fc674ef9da51b1100249cdad19265f768d21d0a19
MD5 a8ffa3f2427e8c9264664118b353e1bb
BLAKE2b-256 c593e3aae78046aa4a9bd21154fdb13a09854dd020cb8312ce38b9bad9788166

See more details on using hashes here.

File details

Details for the file django_wangeditor-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_wangeditor-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1b6f66ab66ece759057ce278c853998d0eab3723889d1f4559a958f8bc05bd24
MD5 5c4750db0dc376396da9e152da340684
BLAKE2b-256 830582db65649630fd6ed0fb692a06fe294cda4bd622d40894a0d45dc980fb83

See more details on using hashes here.

Supported by

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