Skip to content

Commit

Permalink
Add related name to Comments.author (#127)
Browse files Browse the repository at this point in the history
* Add related name to Comments.author

* Migration to support comment fix

* Naming migrations sensibly
  • Loading branch information
bernd-wechner committed Sep 29, 2021
1 parent bbcfd0b commit db406c4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
File renamed without changes.
20 changes: 20 additions & 0 deletions todo/migrations/0012_add_related_name_to_comments.py
@@ -0,0 +1,20 @@
# Generated by Django 2.2.24 on 2021-09-22 22:05

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('todo', '0011_add_related_name_to_created_by'),
]

operations = [
migrations.AlterField(
model_name='comment',
name='author',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='todo_comments', to=settings.AUTH_USER_MODEL),
),
]
3 changes: 2 additions & 1 deletion todo/models.py
Expand Up @@ -133,7 +133,8 @@ class Comment(models.Model):
"""

author = models.ForeignKey(
settings.AUTH_USER_MODEL, on_delete=models.CASCADE, blank=True, null=True
settings.AUTH_USER_MODEL, on_delete=models.CASCADE, blank=True, null=True,
related_name="todo_comments"
)
task = models.ForeignKey(Task, on_delete=models.CASCADE)
date = models.DateTimeField(default=datetime.datetime.now)
Expand Down

0 comments on commit db406c4

Please sign in to comment.