singles快好了
This commit is contained in:
parent
e6cf5995b2
commit
2ab789be16
@ -3,7 +3,6 @@ from pathlib import Path
|
|||||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||||
|
|
||||||
|
|
||||||
# SECURITY WARNING: keep the secret key used in production secret!
|
# SECURITY WARNING: keep the secret key used in production secret!
|
||||||
SECRET_KEY = '+f%vbh_8b+(*kp=clju)691popu%a*#60ik99n4(n2ex9g$)_a'
|
SECRET_KEY = '+f%vbh_8b+(*kp=clju)691popu%a*#60ik99n4(n2ex9g$)_a'
|
||||||
|
|
||||||
@ -63,8 +62,7 @@ TEMPLATES = [
|
|||||||
|
|
||||||
WSGI_APPLICATION = 'SinkDark.wsgi.application'
|
WSGI_APPLICATION = 'SinkDark.wsgi.application'
|
||||||
|
|
||||||
|
"""DATABASES = {
|
||||||
DATABASES = {
|
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.mysql',
|
'ENGINE': 'django.db.backends.mysql',
|
||||||
'NAME': 'test',
|
'NAME': 'test',
|
||||||
@ -72,9 +70,15 @@ DATABASES = {
|
|||||||
'PASSWORD': 'Clever-3366',
|
'PASSWORD': 'Clever-3366',
|
||||||
'HOST': 'crossdark.net',
|
'HOST': 'crossdark.net',
|
||||||
'PORT': '3306',
|
'PORT': '3306',
|
||||||
}
|
},
|
||||||
}
|
}"""
|
||||||
|
|
||||||
|
DATABASES = {
|
||||||
|
'default': {
|
||||||
|
'ENGINE': 'django.db.backends.sqlite3',
|
||||||
|
'NAME': BASE_DIR / 'db.sqlite3',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
AUTH_PASSWORD_VALIDATORS = [
|
AUTH_PASSWORD_VALIDATORS = [
|
||||||
@ -92,8 +96,6 @@ AUTH_PASSWORD_VALIDATORS = [
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
LANGUAGE_CODE = 'en-us'
|
LANGUAGE_CODE = 'en-us'
|
||||||
|
|
||||||
TIME_ZONE = 'UTC'
|
TIME_ZONE = 'UTC'
|
||||||
@ -102,14 +104,11 @@ USE_I18N = True
|
|||||||
|
|
||||||
USE_TZ = True
|
USE_TZ = True
|
||||||
|
|
||||||
|
|
||||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||||
|
|
||||||
# 配置自定义用户模型MyUser
|
# 配置自定义用户模型MyUser
|
||||||
AUTH_USER_MODEL = 'account.MyUser'
|
AUTH_USER_MODEL = 'account.MyUser'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
STATIC_URL = '/static/'
|
STATIC_URL = '/static/'
|
||||||
STATICFILES_DIRS = [BASE_DIR / 'publicStatic']
|
STATICFILES_DIRS = [BASE_DIR / 'publicStatic']
|
||||||
STATIC_ROOT = BASE_DIR / 'static'
|
STATIC_ROOT = BASE_DIR / 'static'
|
||||||
|
@ -4,6 +4,8 @@ from .models import *
|
|||||||
admin.site.site_title = '博客管理后台'
|
admin.site.site_title = '博客管理后台'
|
||||||
admin.site.site_header = '博客管理'
|
admin.site.site_header = '博客管理'
|
||||||
|
|
||||||
|
# admin.site.register(ArticleInfo) # 将文章模型注册到admin后台的mdeditor
|
||||||
|
|
||||||
|
|
||||||
@admin.register(ArticleTag)
|
@admin.register(ArticleTag)
|
||||||
class ArticleTagAdmin(admin.ModelAdmin):
|
class ArticleTagAdmin(admin.ModelAdmin):
|
||||||
|
@ -4,3 +4,7 @@ from django.apps import AppConfig
|
|||||||
class ArticleConfig(AppConfig):
|
class ArticleConfig(AppConfig):
|
||||||
default_auto_field = 'django.db.models.BigAutoField'
|
default_auto_field = 'django.db.models.BigAutoField'
|
||||||
name = 'article'
|
name = 'article'
|
||||||
|
|
||||||
|
def ready(self):
|
||||||
|
from . import signals # 导入signals模块以注册信号处理器
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ class ArticleInfo(models.Model):
|
|||||||
author = models.ForeignKey(MyUser, on_delete=models.CASCADE, verbose_name='用户')
|
author = models.ForeignKey(MyUser, on_delete=models.CASCADE, verbose_name='用户')
|
||||||
title = models.CharField('标题', max_length=200)
|
title = models.CharField('标题', max_length=200)
|
||||||
content = MDTextField(verbose_name='内容')
|
content = MDTextField(verbose_name='内容')
|
||||||
rendered = MDTextField(verbose_name='最终内容', default='<p>默认内容</p>')
|
rendered = RichTextUploadingField(verbose_name='最终内容', default='<p>默认内容</p>')
|
||||||
articlephoto = models.ImageField('文章图片', blank=True, upload_to='images/article/')
|
articlephoto = models.ImageField('文章图片', blank=True, upload_to='images/article/')
|
||||||
reading = models.IntegerField('阅读量', default=0)
|
reading = models.IntegerField('阅读量', default=0)
|
||||||
liking = models.IntegerField('点赞量', default=0)
|
liking = models.IntegerField('点赞量', default=0)
|
||||||
|
15
SinkDark/article/signals.py
Normal file
15
SinkDark/article/signals.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
from django.db.models.signals import post_save
|
||||||
|
from django.dispatch import receiver
|
||||||
|
from .models import ArticleInfo
|
||||||
|
import CrossDown
|
||||||
|
|
||||||
|
|
||||||
|
@receiver(post_save, sender=ArticleInfo)
|
||||||
|
def article_signal_handler(sender, instance, created, **kwargs):
|
||||||
|
if created:
|
||||||
|
# 这里执行你希望在文章创建后自动执行的函数
|
||||||
|
# 例如:
|
||||||
|
print("文章已创建,执行特定函数...")
|
||||||
|
article = ArticleInfo.objects.get(id=instance.id)
|
||||||
|
print(article.content)
|
||||||
|
CrossDown.main(article.content)
|
Loading…
Reference in New Issue
Block a user