diff --git a/.idea/SinkDark.iml b/.idea/SinkDark.iml index 909438d..129c1de 100644 --- a/.idea/SinkDark.iml +++ b/.idea/SinkDark.iml @@ -1,7 +1,9 @@ - + + + diff --git a/.idea/misc.xml b/.idea/misc.xml index a971a2c..a377feb 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,7 @@ + + \ No newline at end of file diff --git a/SinkDark/SinkDark/myadmin.py b/SinkDark/SinkDark/myadmin.py index 4c823c3..b7e9863 100644 --- a/SinkDark/SinkDark/myadmin.py +++ b/SinkDark/SinkDark/myadmin.py @@ -8,6 +8,8 @@ from django.http import HttpResponseRedirect from django.urls import include, path, re_path from django.contrib.contenttypes import views as contenttype_views from django.contrib.auth.views import redirect_to_login + + class MyAdminSite(admin.AdminSite): def admin_view(self, view, cacheable=False): def inner(request, *args, **kwargs): diff --git a/SinkDark/SinkDark/settings.py b/SinkDark/SinkDark/settings.py index 554fdbc..4e855d2 100644 --- a/SinkDark/SinkDark/settings.py +++ b/SinkDark/SinkDark/settings.py @@ -1,5 +1,3 @@ - - from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'. @@ -30,6 +28,7 @@ INSTALLED_APPS = [ 'interflow', 'ckeditor', 'ckeditor_uploader', + 'mdeditor', ] MIDDLEWARE = [ diff --git a/SinkDark/SinkDark/urls.py b/SinkDark/SinkDark/urls.py index bef483f..7fd7700 100644 --- a/SinkDark/SinkDark/urls.py +++ b/SinkDark/SinkDark/urls.py @@ -15,5 +15,6 @@ urlpatterns = [ re_path('static/(?P.*)', serve, {'document_root': settings.STATIC_ROOT}, name='static'), # 设置编辑器的路由信息 path('ckeditor/', include('ckeditor_uploader.urls')), + path('mdeditor/', include('mdeditor.urls')) ] diff --git a/SinkDark/article/models.py b/SinkDark/article/models.py index 74dae34..1af27ca 100644 --- a/SinkDark/article/models.py +++ b/SinkDark/article/models.py @@ -2,6 +2,7 @@ from django.db import models from django.utils import timezone from account.models import MyUser from ckeditor_uploader.fields import RichTextUploadingField +from mdeditor.fields import MDTextField class ArticleTag(models.Model): @@ -20,8 +21,8 @@ class ArticleTag(models.Model): class ArticleInfo(models.Model): author = models.ForeignKey(MyUser, on_delete=models.CASCADE, verbose_name='用户') title = models.CharField('标题', max_length=200) - content = RichTextUploadingField(verbose_name='内容') - rendered = RichTextUploadingField(verbose_name='最终内容', default='

默认内容

') + content = MDTextField(verbose_name='内容') + rendered = MDTextField(verbose_name='最终内容', default='

默认内容

') articlephoto = models.ImageField('文章图片', blank=True, upload_to='images/article/') reading = models.IntegerField('阅读量', default=0) liking = models.IntegerField('点赞量', default=0) diff --git a/requirement.txt b/requirement.txt new file mode 100644 index 0000000..4a8da96 --- /dev/null +++ b/requirement.txt @@ -0,0 +1,2 @@ +django>=5.1.1 +django-mdeditor>=0.1.20