bayketinymce
安装配置
安装
pip install bayketinymce-django
配置
1、在django项目配置文件settings文件中的INSTALLED_APPS注册app,并设置图片上传保存路径
INSTALLED_APPS = [
...
'tinymce',
]
MEDIA_URL = 'media/'
MEDIA_ROOT = BASE_DIR / 'media'
2、上传图片配置
在django项目的根urls.py中引入以下url
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
from tinymce.views import TinyMCEImageUpload
urlpatterns = [
path('admin/', admin.site.urls),
# 富文本编辑器上传图片url
path("tinymce/upload-image/", TinyMCEImageUpload.as_view(), name="tinymce-upload-image")
]
# 开发环境下配置静态文件URL
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
快速使用
在models中使用
from tinymce.fields import TinyMCEField
class Article(models.Model):
content = TinyMCEField()
在forms表单中中使用
# forms.py
from django import forms
from tinymce.forms import TinyMCEField
from tinymce.widgets import TinyMCEWidget
class TinyMCEForm(forms.Form):
content = TinyMCEField(label="详情")
or
content = forms.CharField(widget=TinyMCEWidget(
attrs={"class": 'input'}, tinymce_config={'menubar': False}
)
)
本项目所有的富文本编辑器相关均依赖 TinyMCEWidget 小部件,可以通过定制修改其参数tinymce_config的值(字典)来设置对应的富文本配置,具体配置项请参考tinymce官方配置文档,不支持配置js的方法及函数,仅支持 配置其值为字符串或数组及键值对对象的配置项!
修改默认富文本编辑器配置
在项目的settings.py中引入 TINYMCE_CONFIG 配置,该值是一个字典!
TINYMCE_CONFIG = {
# 是否开启富文本编辑器菜单,默认关闭,这里的配置会覆盖掉默认配置
'menubar': False,
}
Metadata
Release files for bayketinymce-django 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bayketinymce-django-0.0.1.tar.gz | 766.9 kB | Without provenance | Details for bayketinymce-django-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bayketinymce_django-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for bayketinymce_django-0.0.1-py3-none-any.whl |
Total release size: 1.6 MB
Release files / bayketinymce-django-0.0.1.tar.gz
| Download URL | bayketinymce-django-0.0.1.tar.gz |
|---|---|
| Size | 766.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c75ad93c6b798c4acfae1b80162583095fe8ebd1780ef9fc8478710d6147a7da
|
|
BLAKE2b-256 checksum How to use checksums |
6f4a1b0e953ad556602a33137ec52f84a252f496e445a34884f7188bf803d1ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.0
|
Release files / bayketinymce_django-0.0.1-py3-none-any.whl
| Download URL | bayketinymce_django-0.0.1-py3-none-any.whl |
|---|---|
| Size | 824.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
80abdc0e7d8a9869fcad5cc0b959c7e3027deb0d1004faa6ed3c4e107b59338c
|
|
BLAKE2b-256 checksum How to use checksums |
6120f964ef5577f8bd6b9435ca7c877613186de7c9a8be65e2f853e21c0532c1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.0
|
Security for bayketinymce-django 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.