Skip to content

Commit

Permalink
Add auto_now_add to last_updated field. Change updated_by to nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorfs committed Sep 17, 2017
1 parent 35fff32 commit 0dbffbf
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
27 changes: 27 additions & 0 deletions boards/migrations/0002_auto_20170917_1618.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.4 on 2017-09-17 16:18
from __future__ import unicode_literals

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


class Migration(migrations.Migration):

dependencies = [
('boards', '0001_initial'),
]

operations = [
migrations.AlterField(
model_name='post',
name='updated_by',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='+', to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='topic',
name='last_updated',
field=models.DateTimeField(auto_now_add=True),
),
]
4 changes: 2 additions & 2 deletions boards/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def __str__(self):

class Topic(models.Model):
subject = models.CharField(max_length=255)
last_updated = models.DateTimeField()
last_updated = models.DateTimeField(auto_now_add=True)
board = models.ForeignKey(Board, related_name='topics')
starter = models.ForeignKey(User, related_name='topics')

Expand All @@ -23,4 +23,4 @@ class Post(models.Model):
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(null=True)
created_by = models.ForeignKey(User, related_name='posts')
updated_by = models.ForeignKey(User, related_name='+')
updated_by = models.ForeignKey(User, null=True, related_name='+')

0 comments on commit 0dbffbf

Please sign in to comment.