Compare commits

..

No commits in common. "da7075a904b471a6fc2670ebf5e10fbc596e2c19" and "3eae827ed5a499d1c559a305d32b11ac28c4f02e" have entirely different histories.

12 changed files with 0 additions and 92 deletions

View file

@ -35,7 +35,6 @@ INSTALLED_APPS = [
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"flangr.posts",
]
MIDDLEWARE = [
@ -109,5 +108,3 @@ STATIC_URL = "static/"
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
MEDIA_URL = "media/"

View file

@ -15,5 +15,3 @@ DEBUG = True
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = "django-insecure-lt9sfgmvcrjuiz!=l)3f50x&333&p4wi60t1@jdjtrho43ytl+"
MEDIA_ROOT = "./media"

View file

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

View file

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

View file

@ -1,32 +0,0 @@
# Generated by Django 4.0.5 on 2022-07-03 21:35
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = []
operations = [
migrations.CreateModel(
name="Post",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("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()),
],
),
]

View file

@ -1,15 +0,0 @@
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')}"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 320 B

View file

@ -1,26 +0,0 @@
import os
from django.test import TestCase
from django.core.files import File
from .models import Post
# Create your tests here.
class TestPostModelTests(TestCase):
def test_can_create_model(self):
with open(
os.path.join(os.path.dirname(__file__), "test_data", "test_img.png"),
mode="rb",
) as f:
try:
p = Post.objects.create(
img=File(f, "somefile.png"),
title="Foobar",
body="Some file",
)
self.assertIn("Foobar", str(p))
finally:
p.img.delete()

View file

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

View file

@ -1,2 +0,0 @@
pillow
django