mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-27 10:07:05 -05:00
feat: Add blog, media, and support apps, implement ride credits and image API, and remove toplist feature.
This commit is contained in:
45
backend/apps/blog/models.py
Normal file
45
backend/apps/blog/models.py
Normal file
@@ -0,0 +1,45 @@
|
||||
from django.db import models
|
||||
from django.conf import settings
|
||||
from apps.core.models import SluggedModel
|
||||
# Using string reference for CloudflareImage
|
||||
from django_cloudflareimages_toolkit.models import CloudflareImage
|
||||
|
||||
class Tag(SluggedModel):
|
||||
name = models.CharField(max_length=50, unique=True)
|
||||
|
||||
class Meta:
|
||||
ordering = ["name"]
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
class Post(SluggedModel):
|
||||
title = models.CharField(max_length=255)
|
||||
content = models.TextField(help_text="Markdown content supported")
|
||||
excerpt = models.TextField(blank=True, help_text="Short summary for lists")
|
||||
|
||||
image = models.ForeignKey(
|
||||
CloudflareImage,
|
||||
on_delete=models.SET_NULL,
|
||||
null=True,
|
||||
blank=True,
|
||||
related_name="blog_posts",
|
||||
help_text="Featured image"
|
||||
)
|
||||
|
||||
author = models.ForeignKey(
|
||||
settings.AUTH_USER_MODEL,
|
||||
on_delete=models.CASCADE,
|
||||
related_name="blog_posts"
|
||||
)
|
||||
|
||||
published_at = models.DateTimeField(null=True, blank=True, db_index=True)
|
||||
is_published = models.BooleanField(default=False, db_index=True)
|
||||
|
||||
tags = models.ManyToManyField(Tag, blank=True, related_name="posts")
|
||||
|
||||
class Meta:
|
||||
ordering = ["-published_at", "-created_at"]
|
||||
|
||||
def __str__(self):
|
||||
return self.title
|
||||
Reference in New Issue
Block a user