공지사항관리 기능 분리 및 개선
All checks were successful
Build And Test / build-and-push (push) Successful in 4m23s
All checks were successful
Build And Test / build-and-push (push) Successful in 4m23s
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
from django.db import models
|
||||
from django.conf import settings
|
||||
from django.urls import reverse
|
||||
from markdown_it import MarkdownIt
|
||||
from taggit.managers import TaggableManager
|
||||
|
||||
@ -10,12 +11,20 @@ class Post(models.Model):
|
||||
created_at = models.DateTimeField(auto_now_add=True) # 작성일
|
||||
updated_at = models.DateTimeField(auto_now=True) # 수정일
|
||||
tags = TaggableManager()
|
||||
author = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, on_delete=models.CASCADE)
|
||||
author = models.ForeignKey(
|
||||
settings.AUTH_USER_MODEL,
|
||||
null=True,
|
||||
on_delete=models.CASCADE,
|
||||
related_name='blog_posts'
|
||||
)
|
||||
|
||||
def render_markdown(self):
|
||||
"""마크다운을 HTML로 변환"""
|
||||
md = MarkdownIt()
|
||||
return md.render(self.contents)
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse('blog:post_detail', args=[str(self.pk)])
|
||||
|
||||
def __str__(self):
|
||||
return self.title
|
||||
Reference in New Issue
Block a user