Commit 1b22d175 authored by Alec Dayupay's avatar Alec Dayupay

Merged forumv2

parent 333ca3b6
# Generated by Django 3.2 on 2023-05-04 03:59
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('forum', '0003_alter_forumpost_pub_datetime'),
]
operations = [
migrations.AlterField(
model_name='reply',
name='pub_datetime',
field=models.DateTimeField(auto_now_add=True),
),
]
......@@ -19,7 +19,7 @@ class ForumPost(models.Model):
class Reply(models.Model):
body = models.TextField()
author = models.ForeignKey('dashboard.WidgetUser', on_delete=models.CASCADE)
pub_datetime = models.DateTimeField()
pub_datetime = models.DateTimeField(auto_now_add=True)
forum_post = models.ForeignKey('ForumPost', on_delete=models.CASCADE, null= True )
def __str__(self):
......
......@@ -4,7 +4,7 @@ from django.views.generic.edit import CreateView, UpdateView
from .models import ForumPost
def forum(request):
return render(request, 'forum/forum.html', {'forumposts': ForumPost.objects.all()})
return render(request, 'forum/forum.html', {'forumposts': ForumPost.objects.order_by('-pub_datetime')})
class ForumPostDetailView(DetailView):
model = ForumPost
......
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