blog post init

This commit is contained in:
Pratyush Desai 2022-01-08 12:21:22 +05:30
parent b690967d5d
commit 47bbec8dfe
Signed by: pratyush
GPG Key ID: DBA5BB7505946FAD
3 changed files with 20 additions and 13 deletions

View File

@ -1,3 +1,5 @@
from django.contrib import admin from django.contrib import admin
# Register your models here. from blog.models import *
admin.site.register(Post)

View File

@ -1,6 +1,7 @@
# Generated by Django 4.0 on 2022-01-07 23:05 # Generated by Django 4.0 on 2022-01-08 06:45
from django.db import migrations, models from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration): class Migration(migrations.Migration):
@ -8,6 +9,7 @@ class Migration(migrations.Migration):
initial = True initial = True
dependencies = [ dependencies = [
('auth', '0012_alter_user_first_name_max_length'),
] ]
operations = [ operations = [
@ -15,10 +17,13 @@ class Migration(migrations.Migration):
name='Post', name='Post',
fields=[ fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=200, unique=True)), ('created', models.DateTimeField(auto_now_add=True)),
('updated_on', models.DateTimeField(auto_now=True)), ('title', models.CharField(blank=True, default='', max_length=100)),
('created_on', models.DateTimeField(auto_now_add=True)), ('body', models.TextField(blank=True, default='')),
('content', models.TextField()), ('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='posts', to='auth.user')),
], ],
options={
'ordering': ['created'],
},
), ),
] ]

View File

@ -8,11 +8,11 @@ STATUS = (
(1,"Publish") (1,"Publish")
) )
# Create your models here. # Create your models here.
class Post(models.Model): class Post(models.Model):
title = models.CharField(max_length=200, unique=True) created = models.DateTimeField(auto_now_add=True)
# author = models.ForeignKey('user.auth',on_delete=models.CASCADE) title = models.CharField(max_length=100, blank=True, default='')
updated_on =models.DateTimeField(auto_now= True) body = models.TextField(blank=True, default='')
created_on = models.DateTimeField(auto_now_add=True) owner = models.ForeignKey('auth.User', related_name='posts', on_delete=models.CASCADE)
content = models.TextField()
# status = models.IntegerChoices() class Meta:
ordering = ['created']