Compare commits

...

2 Commits

Author SHA1 Message Date
47bbec8dfe
blog post init 2022-01-08 12:21:22 +05:30
b690967d5d
drfauth 2022-01-08 12:02:25 +05:30
4 changed files with 25 additions and 14 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']

View File

@ -128,5 +128,9 @@ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
REST_FRAMEWORK = { REST_FRAMEWORK = {
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination', 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
'PAGE_SIZE': 10 'PAGE_SIZE': 10,
'DEFAULT_AUTHENTICATION_CLASSES': [
'rest_framework.authentication.BasicAuthentication',
'rest_framework.authentication.SessionAuthentication',
]
} }