All checks were successful
Build And Test / build-and-push (push) Successful in 4m23s
27 lines
886 B
Python
27 lines
886 B
Python
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 |