Commit e58a39fe authored by Eldon Dagdag's avatar Eldon Dagdag

Fixed forum app model fields

parent efdfc2ff
......@@ -11,6 +11,5 @@ class ForumPostAdmin(admin.ModelAdmin):
list_filter = ('title', 'author',)
inlines = [ReplyInline]
# Register your models here.
admin.site.register(Reply)
admin.site.register(ForumPost, ForumPostAdmin)
\ No newline at end of file
# Generated by Django 4.1.7 on 2023-03-06 07:15
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('forum', '0005_rename_reply_reply_reply_to'),
]
operations = [
migrations.RenameField(
model_name='reply',
old_name='reply_to',
new_name='forum_post',
),
]
......@@ -11,12 +11,10 @@ class ForumPost(models.Model):
return '{} by {} on {}'.format(self.title, self.author, self.pub_datetime.strftime("%m/%d/%Y %I:%M %p"))
class Reply(models.Model):
reply_to = models.ForeignKey(ForumPost, on_delete=models.CASCADE, default='')
body = models.TextField(default='')
author = models.ForeignKey(dashboard_models.WidgetUser, on_delete=models.CASCADE)
pub_datetime = models.DateTimeField(auto_now=False, auto_now_add=False)
forum_post = models.ForeignKey(ForumPost, on_delete=models.CASCADE, default='')
def __str__(self):
return 'Reply by {} on {}'.format(self.author, self.pub_datetime.strftime("%m/%d/%Y %I:%M %p"))
# Create your models here.
......@@ -15,7 +15,7 @@ def index(request):
return_string += post_string
for reply in Reply.objects.all():
if post == reply.reply_to:
if post == reply.forum_post:
reply_string = 'Reply by {} {} posted {}:<br>'.format(
reply.author.first_name, reply.author.last_name,
reply.pub_datetime.strftime("%m/%d/%Y, %I:%M %p")
......@@ -29,4 +29,3 @@ def index(request):
html_string = '<html><body>{}</body></html>'.format(return_string)
return HttpResponse(return_string)
# Create your views here.
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