Add default author for articles
This commit is contained in:
parent
f0e3048a24
commit
b893e8b64e
2 changed files with 25 additions and 1 deletions
24
articles/migrations/0008_auto_20200817_1748.py
Normal file
24
articles/migrations/0008_auto_20200817_1748.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
# Generated by Django 3.1 on 2020-08-17 15:48
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("articles", "0007_auto_20200817_0941"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="article",
|
||||
name="author",
|
||||
field=models.ForeignKey(
|
||||
default=1,
|
||||
on_delete=django.db.models.deletion.PROTECT,
|
||||
to=settings.AUTH_USER_MODEL,
|
||||
),
|
||||
),
|
||||
]
|
|
@ -31,7 +31,7 @@ class Article(models.Model):
|
|||
published_at = models.DateTimeField(null=True, blank=True)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
author = models.ForeignKey(User, on_delete=models.PROTECT)
|
||||
author = models.ForeignKey(User, on_delete=models.PROTECT, default=1)
|
||||
views_count = models.IntegerField(default=0)
|
||||
slug = models.SlugField(unique=True)
|
||||
|
||||
|
|
Reference in a new issue