Django admin KindEditor integration.
Project description
django-kindeditor
This repo is to make it easy to use KindEditor as a RichTextEditor when using django.
You can visit this site to see the editor result: http://kindeditor.org/
Requires
- Django 2.0+
- Python 3.6+
Usage
- Install
pip install django-kindeditor
- Add
kindeditor
to INSTALL_APPS in settings, and define static, media
INSTALLED_APPS = [
...
'kindeditor',
]
...
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static') # your static files path
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media') # your media files path
- Insert "kindeditor/" path and static, media paths to urlpatterns in urls.py
from django.conf import settings
if settings.DEBUG:
# static and media
from django.conf.urls.static import static
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
urlpatterns.extend(
staticfiles_urlpatterns()
+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
)
urlpatterns = [
...
path("kindeditor/", include("kindeditor.urls")),
]
if settings.DEBUG:
# static and media
from django.conf.urls.static import static
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
urlpatterns.extend(
staticfiles_urlpatterns()
+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
)
Example
# models.py
from kindeditor import RichTextField
class Article(models.Model):
title = models.CharField(max_length=80)
content = RichTextField()
# settings.py
KINDEDITOR_UPLOAD_PERMISSION = 'admin'
# admin.py
from django.contrib import admin
from kindeditor import EditorAdmin
from .models import Article
admin.site.register(Article, EditorAdmin)
Demo
-
Clone the repo to local
git clone https://github.com/waketzheng/django-kindeditor
-
Create a virtual environment and install required packages
pipenv install --dev
-
Activate it
pipenv shell
-
Migrate and compile translation file
./manage.py migrate ./manage.py compilemessages
-
Runserver
./manage.py runserver
-
View the url and you will see the demo at webbrowser.
Development
- Test Coverage
coverage run ./manage.py test
- Test multiple django versions
tox
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-kindeditor-0.2.0.tar.gz
(516.3 kB
view hashes)
Built Distribution
Close
Hashes for django_kindeditor-0.2.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17636206020447fb436eed2a2491a8780589f80aa7b1e66dcddfbbd1ea896212 |
|
MD5 | 802a9de7f7176936361feac31c0a9841 |
|
BLAKE2b-256 | 61c8126fabf0d8bf75771ac546c9ea1fc2111d0db68d1f061d81cbdbc5958ad5 |