|
@@ -183,16 +183,19 @@ def add_article(request):
|
|
is_top = request.POST['is_top']
|
|
is_top = request.POST['is_top']
|
|
|
|
|
|
category_obj = models.Category.objects.get(id=category)
|
|
category_obj = models.Category.objects.get(id=category)
|
|
- now_utc = timezone.now() # aware UTC 时间
|
|
|
|
- # ① 如果你想要 UTC+8:
|
|
|
|
- beijing_time = now_utc + timedelta(hours=8)
|
|
|
|
|
|
+
|
|
article_obj = models.Article.objects.create(title=title, intro=intro, category=category_obj,
|
|
article_obj = models.Article.objects.create(title=title, intro=intro, category=category_obj,
|
|
html_text=html_text,
|
|
html_text=html_text,
|
|
markdown_text=markdown_text,
|
|
markdown_text=markdown_text,
|
|
type=type_, status=status, user=request.user,
|
|
type=type_, status=status, user=request.user,
|
|
- created_time=beijing_time,
|
|
|
|
|
|
+ created_time=datetime.now() ,
|
|
is_top=is_top
|
|
is_top=is_top
|
|
)
|
|
)
|
|
|
|
+ now_utc = timezone.now()
|
|
|
|
+ plus_eight = now_utc + timedelta(hours=8)
|
|
|
|
+
|
|
|
|
+ article_obj.created_time = plus_eight
|
|
|
|
+ article_obj.save(update_fields=['created_time'])
|
|
tags_id = []
|
|
tags_id = []
|
|
for tag in str(tags).split(','):
|
|
for tag in str(tags).split(','):
|
|
if tag == '':
|
|
if tag == '':
|