from django.contrib import admin from .models import Post, Category, Comment # Register your models here. classCategoryAdmin(admin.ModelAdmin): # 미리 만들어지는 field # slug를 자동으로 만들어준다. prepopulated_fields = {'slug': ('name', )} admin.site.register(Post) admin.site.register(Comment) admin.site.register(Category, CategoryAdmin)
markdown 적용해주기
blog/models.py
classComment(models.Model): post = models.ForeignKey(Post, on_delete=models.CASCADE) text = MarkdownxField() author = models.ForeignKey(User, on_delete=models.CASCADE) # markdown을 html로 바꿔준다. defget_markdwon_content(self): return markdown(self.text)