notice 등록 기능 구현

This commit is contained in:
sdjo
2025-01-17 15:41:11 +09:00
parent 150046da1d
commit 819d554bac
10 changed files with 115 additions and 11 deletions

View File

@ -5,10 +5,10 @@ from .models import Post
class PostForm(forms.ModelForm):
class Meta:
model = Post
fields = ['title', 'content', 'summary', 'tags']
fields = ['title', 'contents', 'summary', 'tags']
widgets = {
'title': forms.TextInput(attrs={'class': 'form-control'}),
'content': forms.Textarea(attrs={'class': 'form-control', 'id': 'markdown-editor'}),
'contents': forms.Textarea(attrs={'class': 'form-control', 'id': 'markdown-editor'}),
'summary': forms.TextInput(attrs={'class': 'form-control'}),
'tags': TagWidget(attrs={'class': 'form-control', 'placeholder': 'Add tags'}),
}

View File

@ -0,0 +1,18 @@
# Generated by Django 4.2.14 on 2025-01-17 15:36
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('blog', '0004_remove_post_tags_post_tags'),
]
operations = [
migrations.RenameField(
model_name='post',
old_name='content',
new_name='contents',
),
]

View File

@ -5,7 +5,7 @@ from taggit.managers import TaggableManager
class Post(models.Model):
title = models.CharField(max_length=200) # 제목
content = models.TextField() # 본문 (마크다운 저장)
contents = models.TextField() # 본문 (마크다운 저장)
summary = models.CharField(max_length=2000, blank=True, null=True) # 요약
created_at = models.DateTimeField(auto_now_add=True) # 작성일
updated_at = models.DateTimeField(auto_now=True) # 수정일
@ -15,7 +15,7 @@ class Post(models.Model):
def render_markdown(self):
"""마크다운을 HTML로 변환"""
md = MarkdownIt()
return md.render(self.content)
return md.render(self.contents)
def __str__(self):
return self.title

View File

@ -25,7 +25,7 @@
<h2>contents</h2>
<div class="col-md-12">
{{ form.content }}
{{ form.contents }}
</div>
<!-- 버튼 -->
<div class="d-flex justify-content-end mt-4">