A simple Django app to edit markdown text.
Project description
不一样的
- 极简
- 第三方存储
快速开始
安装
pip install django-mditor
将 mditor 添加到您的 INSTALLED_APPS 设置中,如下所示:
INSTALLED_APPS = [
# ...
'mditor',
]
将 meida 网址添加到您的设置中,如下所示:
MEDIA_ROOT = os.path.join(BASE_DIR, 'uploads')
MEDIA_URL = '/media/'
像这样将 url 添加到您的 url.py 中:
from django.conf.urls import url, include
from django.conf.urls.static import static
from django.conf import settings
# 省略 ...
urlpatterns = [
# 省略 ...
url(r'mditor/', include('mditor.urls'))
]
if settings.DEBUG:
# static files (images, css, javascript, etc.)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
像这样写你的模型:
from django.db import models
from mditor.fields import MarkDownField
class Article(models.Model):
"""
文章
"""
title = models.CharField('标题', max_length=100)
body = MarkDownField('正文')
常规操作:
- 在 admin.py 中注册您的模型
- 运行 python manage.py makemigrations 和 python manage.py migrate 来创建你的模型。
- 登录 Admin ,您可以看到一个编辑器文本字段。
自定义配置:
settings.py
MDITOR_CONFIGS = {
"default": {
"width": "auto",
"MinWidth": "535px",
"MaxWidth": "880px",
"height": "450px",
"preview": "false",
"split": "false",
"fullscreen": "false",
"upload_image_formats": ["jpg", "jpeg", "gif", "png", "bmp", "webp"],
"image_folder": "mditor",
}
}
问题?
是否支持第三方存储?
django-mditor 调用 setting.py 中 DEFAULT_FILE_STORAGE,修改 DEFAULT_FILE_STORAGE 即可
目前已测试 阿里云 OSS,其他尚未测试。
如何将markdown内容渲染成html5?
参考 markdown
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
django-mditor-0.0.12.tar.gz
(754.6 kB
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 django-mditor-0.0.12.tar.gz.
File metadata
- Download URL: django-mditor-0.0.12.tar.gz
- Upload date:
- Size: 754.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.7.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f2cfc0c8a951b62382320406392de158f10b9b4086459b2089eae2a5f2d673ee
|
|
| MD5 |
7cef1dd18e831301a531649be7b457a6
|
|
| BLAKE2b-256 |
4532d8d5fd62ac2a0d5641da0fbc3df698bf204fc564ea87fe53ffc9f1f0e71d
|
File details
Details for the file django_mditor-0.0.12-py3-none-any.whl.
File metadata
- Download URL: django_mditor-0.0.12-py3-none-any.whl
- Upload date:
- Size: 757.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.7.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ec9316b55d540a4bd25a486526e40e59094423c09ae37f7149d31eb1aecc4c2
|
|
| MD5 |
5f1f2a8fd165343c318fb80dde6f5216
|
|
| BLAKE2b-256 |
c347bb4073cd3dc45708428e0cc65fd2be2851ad3209f331ed649a1f05b047b4
|