Add default author for articles

This commit is contained in:
Gabriel Augendre 2020-08-17 17:49:19 +02:00
parent f0e3048a24
commit b893e8b64e
2 changed files with 25 additions and 1 deletions

View 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,
),
),
]

View file

@ -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)