Add Post model

This commit is contained in:
Maximilian Friedersdorff 2022-07-03 22:20:22 +01:00
parent 3eae827ed5
commit a983121a55
7 changed files with 30 additions and 0 deletions

0
flangr/posts/__init__.py Normal file
View file

3
flangr/posts/admin.py Normal file
View file

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

6
flangr/posts/apps.py Normal file
View file

@ -0,0 +1,6 @@
from django.apps import AppConfig
class PostsConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "flangr.posts"

View file

15
flangr/posts/models.py Normal file
View file

@ -0,0 +1,15 @@
from django.db import models
# Create your models here.
class Post(models.Model):
img = models.ImageField(upload_to="posts/%Y/%m")
posted = models.DateTiemField(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')}"

3
flangr/posts/tests.py Normal file
View file

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

3
flangr/posts/views.py Normal file
View file

@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.