Modify and add rich text editor on the Django 2.0 admin background management interface, djangoadmin
1. File Path:
For example, if the Python environment is on the drive F: \ My \ django \ env \ Lib \ site-packages \ django \ contrib \ admin \ templates \ admin \
2. Modify the logon Interface Name:
Initial Django Logon: F: \ My \ django \ env \ Lib \ site-packages \ django \ contrib \ admin \ templates \ admin \ base_site.htmlmodify the name of base_site.html: {% extends "admin/base.html" % }{% block title %} Welcome to | management background of the official website of xxx environmental protection technology {% endblock % }{% block branding %}
Display
3. Modify the background interface style:
Style File Path: F: \ My \ django \ env \ Lib \ site-packages \ django \ contrib \ admin \ static \ admin \ css \ base.css
4. Django Background Chinese and Time Zone Configuration:
In settings. py: Export age_code = 'zh-hans 'time _ ZONE = 'Asia/Shanghai'
5. Modify the name of the app displayed in the Admin background using Django:
In F: \ project \ yxhb \ app \ apps. add: class AppConfig (AppConfig): name = 'app' verbose _ name = "official website management background" To The py file in F: \ project \ yxhb \ app \__ init __. py initialization: default_app_config = 'app. apps. appconfig'
Display
6. Add a Rich Text Editor:
Install django-ckeditor:
Pip install django-ckeditor Add: INSTALLED_APPS = ['ckediter', 'ckeditor _ upload'] to the settings configuration of Django to ensure that the media path is configured, And the ckeditor upload path is under media, my configuration is also in media/upload, MEDIA_URL = '/media/' MEDIA _ ROOT = OS. path. join (BASE_DIR, 'Media ') CKEDITOR_UPLOAD_PATH = 'images/' add urls, that is, set url for ckeditor: urlpatterns = [url (r '^ admin/', admin. site. urls), url (r 'ckeditor/', include ('ckeditor _ uploader. urls ')] use the new data type and add: from django in models. db import modelsfrom ckeditor_uploader.fields import RichTextUploadingFieldclass Post (models. model): content = RichTextUploadingField (null = True, blank = True)