Add dummy data
This commit is contained in:
parent
e3e1a0144c
commit
8ea8476cc8
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/static/admin/
|
@ -1,3 +1,11 @@
|
|||||||
from django.contrib import admin
|
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.
|
|
||||||
|
33
apps/back/migrations/0001_initial.py
Normal file
33
apps/back/migrations/0001_initial.py
Normal 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'],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
31
apps/back/migrations/0002_auto_20210309_2020.py
Normal file
31
apps/back/migrations/0002_auto_20210309_2020.py
Normal 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'],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
22
apps/back/migrations/0003_auto_20210309_2038.py
Normal file
22
apps/back/migrations/0003_auto_20210309_2038.py
Normal 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),
|
||||||
|
),
|
||||||
|
]
|
@ -1,3 +1,32 @@
|
|||||||
from django.db import models
|
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
4992
comments.json
Normal file
File diff suppressed because it is too large
Load Diff
BIN
db.sqlite3
Normal file
BIN
db.sqlite3
Normal file
Binary file not shown.
@ -2,17 +2,6 @@ version: '3.1'
|
|||||||
|
|
||||||
services:
|
services:
|
||||||
|
|
||||||
db:
|
|
||||||
image: postgres
|
|
||||||
restart: always
|
|
||||||
volumes:
|
|
||||||
- ./../postgres_data:/var/lib/postgresql/data
|
|
||||||
environment:
|
|
||||||
POSTGRES_DB: demo
|
|
||||||
POSTGRES_PASSWORD: postgres
|
|
||||||
expose:
|
|
||||||
- 5432
|
|
||||||
|
|
||||||
django:
|
django:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
@ -25,19 +14,12 @@ services:
|
|||||||
DEBUG: "True"
|
DEBUG: "True"
|
||||||
ALLOWED_HOSTS: "localhost"
|
ALLOWED_HOSTS: "localhost"
|
||||||
SECRET_KEY: "mysecret"
|
SECRET_KEY: "mysecret"
|
||||||
DB_HOST: db
|
DOMAIN: "my-demo.localhost"
|
||||||
DB_NAME: "demo"
|
DOMAIN_URL: "http://my-demo.localhost"
|
||||||
DB_USER: "postgres"
|
|
||||||
DB_PASSWORD: "postgres"
|
|
||||||
DB_PORT: "5432"
|
|
||||||
DOMAIN: "localhost"
|
|
||||||
DOMAIN_URL: "http://localhost"
|
|
||||||
STATIC_URL: "/static/"
|
STATIC_URL: "/static/"
|
||||||
MEDIA_URL: "/media/"
|
MEDIA_URL: "/media/"
|
||||||
expose:
|
expose:
|
||||||
- 8000
|
- 8000
|
||||||
depends_on:
|
|
||||||
- db
|
|
||||||
|
|
||||||
redis:
|
redis:
|
||||||
image: redis:alpine
|
image: redis:alpine
|
||||||
@ -56,7 +38,7 @@ services:
|
|||||||
- 443:443
|
- 443:443
|
||||||
volumes:
|
volumes:
|
||||||
- ./Caddyfile:/etc/caddy/Caddyfile
|
- ./Caddyfile:/etc/caddy/Caddyfile
|
||||||
- ./../caddy_data:/data
|
- ./caddy_data:/data
|
||||||
- .:/usr/src/app/
|
- .:/usr/src/app/
|
||||||
depends_on:
|
depends_on:
|
||||||
- django
|
- django
|
@ -77,16 +77,10 @@ TEMPLATES = [
|
|||||||
|
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
'ENGINE': 'django.db.backends.postgresql',
|
'ENGINE': 'django.db.backends.sqlite3',
|
||||||
'NAME': 'demo',
|
'NAME': BASE_DIR / 'db.sqlite3',
|
||||||
'USER': 'postgres',
|
|
||||||
'PASSWORD': 'postgres',
|
|
||||||
'HOST': '127.0.0.1',
|
|
||||||
'PORT': '5432',
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Password validation
|
# Password validation
|
||||||
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
|
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
|
||||||
|
|
||||||
@ -117,13 +111,14 @@ USE_I18N = False
|
|||||||
|
|
||||||
USE_L10N = False
|
USE_L10N = False
|
||||||
|
|
||||||
USE_TZ = False
|
USE_TZ = True
|
||||||
|
|
||||||
|
|
||||||
# Static files (CSS, JavaScript, Images)
|
# Static files (CSS, JavaScript, Images)
|
||||||
# https://docs.djangoproject.com/en/3.1/howto/static-files/
|
# https://docs.djangoproject.com/en/3.1/howto/static-files/
|
||||||
|
|
||||||
STATIC_URL = '/static/'
|
STATIC_URL = '/static/'
|
||||||
|
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
|
||||||
|
|
||||||
ASGI_APPLICATION = "asgi.application"
|
ASGI_APPLICATION = "asgi.application"
|
||||||
|
|
||||||
|
1081
posts.json
Normal file
1081
posts.json
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user