Add dummy data

This commit is contained in:
Andros Fenollosa 2021-03-09 22:03:17 +01:00
parent e3e1a0144c
commit 8ea8476cc8
11 changed files with 6206 additions and 32 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/static/admin/

View File

@ -1,3 +1,11 @@
from django.contrib import admin
from .models import Post, Comment
@admin.register(Post)
class PostAdmin(admin.ModelAdmin):
pass
@admin.register(Comment)
class CommentAdmin(admin.ModelAdmin):
pass
# Register your models here.

View File

@ -0,0 +1,33 @@
# Generated by Django 3.1.7 on 2021-03-09 20:10
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='Post',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=200, unique=True)),
('slug', models.SlugField(max_length=200, unique=True)),
('updated_on', models.DateTimeField(auto_now=True)),
('content', models.TextField()),
('created_on', models.DateTimeField(auto_now_add=True)),
('status', models.IntegerField(choices=[(0, 'Draft'), (1, 'Publish')], default=0)),
('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='blog_posts', to=settings.AUTH_USER_MODEL)),
],
options={
'ordering': ['-created_on'],
},
),
]

View File

@ -0,0 +1,31 @@
# Generated by Django 3.1.7 on 2021-03-09 20:20
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('back', '0001_initial'),
]
operations = [
migrations.RemoveField(
model_name='post',
name='updated_on',
),
migrations.CreateModel(
name='Comment',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=20)),
('body', models.CharField(max_length=128)),
('created_on', models.DateTimeField(auto_now_add=True)),
('post', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='back.post')),
],
options={
'ordering': ['-created_on'],
},
),
]

View File

@ -0,0 +1,22 @@
# Generated by Django 3.1.7 on 2021-03-09 20:38
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('back', '0002_auto_20210309_2020'),
]
operations = [
migrations.RemoveField(
model_name='post',
name='slug',
),
migrations.AlterField(
model_name='post',
name='author',
field=models.CharField(max_length=20),
),
]

View File

@ -1,3 +1,32 @@
from django.db import models
# Create your models here.
STATUS = (
(0,"Draft"),
(1,"Publish")
)
class Post(models.Model):
title = models.CharField(max_length=200, unique=True)
author = models.CharField(max_length=20)
content = models.TextField()
status = models.IntegerField(choices=STATUS, default=0)
created_on = models.DateTimeField(auto_now_add=True)
class Meta:
ordering = ['-created_on']
def __str__(self):
return self.title
class Comment(models.Model):
name = models.CharField(max_length=20)
body = models.CharField(max_length=128)
post = models.ForeignKey(Post, on_delete= models.CASCADE)
created_on = models.DateTimeField(auto_now_add=True)
class Meta:
ordering = ['-created_on']
def __str__(self):
return self.name

4992
comments.json Normal file

File diff suppressed because it is too large Load Diff

BIN
db.sqlite3 Normal file

Binary file not shown.

View File

@ -2,17 +2,6 @@ version: '3.1'
services:
db:
image: postgres
restart: always
volumes:
- ./../postgres_data:/var/lib/postgresql/data
environment:
POSTGRES_DB: demo
POSTGRES_PASSWORD: postgres
expose:
- 5432
django:
build:
context: .
@ -25,19 +14,12 @@ services:
DEBUG: "True"
ALLOWED_HOSTS: "localhost"
SECRET_KEY: "mysecret"
DB_HOST: db
DB_NAME: "demo"
DB_USER: "postgres"
DB_PASSWORD: "postgres"
DB_PORT: "5432"
DOMAIN: "localhost"
DOMAIN_URL: "http://localhost"
DOMAIN: "my-demo.localhost"
DOMAIN_URL: "http://my-demo.localhost"
STATIC_URL: "/static/"
MEDIA_URL: "/media/"
expose:
- 8000
depends_on:
- db
redis:
image: redis:alpine
@ -56,7 +38,7 @@ services:
- 443:443
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
- ./../caddy_data:/data
- ./caddy_data:/data
- .:/usr/src/app/
depends_on:
- django

View File

@ -77,16 +77,10 @@ TEMPLATES = [
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'demo',
'USER': 'postgres',
'PASSWORD': 'postgres',
'HOST': '127.0.0.1',
'PORT': '5432',
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
# Password validation
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
@ -117,13 +111,14 @@ USE_I18N = False
USE_L10N = False
USE_TZ = False
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.1/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
ASGI_APPLICATION = "asgi.application"

1081
posts.json Normal file

File diff suppressed because it is too large Load Diff