Commit 0405795c authored by Fritzie Dianne Del Pilar's avatar Fritzie Dianne Del Pilar
parents 272af3ff ccb43ba0
File deleted
# Generated by Django 3.2 on 2023-03-06 05:46
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
('dashboard', '0001_initial'),
('forum', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='reply',
name='forum_post',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='forum.forumpost'),
),
migrations.AlterField(
model_name='forumpost',
name='author',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='dashboard.widgetuser'),
),
migrations.AlterField(
model_name='reply',
name='author',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='dashboard.widgetuser'),
),
migrations.AlterField(
model_name='reply',
name='pub_datetime',
field=models.DateTimeField(blank=True, default=django.utils.timezone.now, null=True),
),
]
......@@ -14,10 +14,13 @@ class ForumPost(models.Model):
class Reply(models.Model):
post = models.ForeignKey(ForumPost, on_delete=models.CASCADE, null=True)
forum_post = models.ForeignKey(ForumPost, on_delete=models.CASCADE, null=True)
body = models.TextField()
author = models.ForeignKey(WidgetUser, on_delete=models.CASCADE)
pub_datetime = models.DateTimeField(default=timezone.now, null=True, blank=True)
def __str__(self):
return self.post
\ No newline at end of file
return 'Reply by {} {} posted {}'.format(
self.author.first_name, self.author.last_name,
self.pub_datetime.strftime('%m/%d/%Y, %H:%M %p')
)
\ No newline at end of file
......@@ -12,7 +12,7 @@ def index(request):
post.pub_datetime.strftime('%m/%d/%Y, %H:%M %p'), post.body
)
for reply in Reply.objects.all():
if reply.post==post.title:
if reply.forum_post.title==post.title:
page_content += 'Reply by {} {} posted {}:<br>{}<br>'.format(
reply.author.first_name, reply.author.last_name,
reply.pub_datetime.strftime('%m/%d/%Y, %H:%M %p'),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment