flangr/flangr/posts/models.py

15 lines
420 B
Python

from django.db import models
# Create your models here.
class Post(models.Model):
img = models.ImageField(upload_to="posts/%Y/%m")
posted = models.DateTimeField(auto_now_add=True)
public = models.BooleanField(default=False)
title = models.CharField(max_length=255)
body = models.TextField()
def __str__(self):
return f"Post: {self.title} at {self.posted.strftime('%Y-%m-%d %H:%S')}"