공지사항관리 기능 분리 및 개선
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:
27
board_notice/models.py
Normal file
27
board_notice/models.py
Normal file
@ -0,0 +1,27 @@
|
||||
from django.db import models
|
||||
from django.conf import settings
|
||||
from django.urls import reverse
|
||||
from markdown_it import MarkdownIt
|
||||
|
||||
class BoardNotice(models.Model):
|
||||
title = models.CharField(max_length=200) # 제목
|
||||
contents = models.TextField() # 본문 (마크다운 저장)
|
||||
created_at = models.DateTimeField(auto_now_add=True) # 작성일
|
||||
updated_at = models.DateTimeField(auto_now=True) # 수정일
|
||||
author = models.ForeignKey(
|
||||
settings.AUTH_USER_MODEL,
|
||||
null=True,
|
||||
on_delete=models.CASCADE,
|
||||
related_name='board_notice'
|
||||
)
|
||||
|
||||
def render_markdown(self):
|
||||
"""마크다운을 HTML로 변환"""
|
||||
md = MarkdownIt()
|
||||
return md.render(self.contents)
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse('board_notice:notice_detail', args=[str(self.pk)])
|
||||
|
||||
def __str__(self):
|
||||
return self.title
|
||||
Reference in New Issue
Block a user