Skip to content

Commit

Permalink
add models.SET_NULL for last_post
Browse files Browse the repository at this point in the history
  • Loading branch information
vicalloy committed Aug 11, 2016
1 parent d5550d4 commit 06a9b77
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
26 changes: 26 additions & 0 deletions lbforum/migrations/0002_auto_20160811_0211.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10 on 2016-08-11 02:11
from __future__ import unicode_literals

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


class Migration(migrations.Migration):

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

operations = [
migrations.AlterField(
model_name='forum',
name='last_post',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='lbforum.Post', verbose_name='Last post'),
),
migrations.AlterField(
model_name='topic',
name='last_post',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='last_post_topics', to='lbforum.Post', verbose_name='Last post'),
),
]
10 changes: 6 additions & 4 deletions lbforum/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ class Forum(models.Model):
num_topics = models.IntegerField(default=0)
num_posts = models.IntegerField(default=0)

last_post = models.ForeignKey( # TODO set none
'Post', verbose_name=_('Last post'),
last_post = models.ForeignKey(
'Post', models.SET_NULL,
verbose_name=_('Last post'),
blank=True, null=True)

class Meta:
Expand Down Expand Up @@ -116,8 +117,9 @@ class Topic(models.Model):
created_on = models.DateTimeField(auto_now_add=True)
updated_on = models.DateTimeField(blank=True, null=True)
last_reply_on = models.DateTimeField(auto_now_add=True)
last_post = models.ForeignKey( # TODO set none
'Post', verbose_name=_('Last post'),
last_post = models.ForeignKey(
'Post', models.SET_NULL,
verbose_name=_('Last post'),
related_name='last_post_topics', blank=True, null=True)

has_imgs = models.BooleanField(default=False)
Expand Down

0 comments on commit 06a9b77

Please sign in to comment.