Commit 630a64c6 authored by Trisha Angel Millena's avatar Trisha Angel Millena

Edited models.py and views.py

parent 66bb255a
File added
...@@ -8,7 +8,7 @@ class ForumPost(models.Model): ...@@ -8,7 +8,7 @@ class ForumPost(models.Model):
title = models.CharField(max_length = 300) title = models.CharField(max_length = 300)
body = models.TextField(max_length = 500) body = models.TextField(max_length = 500)
author = models.ForeignKey(WidgetUser, on_delete = models.CASCADE) author = models.ForeignKey(WidgetUser, on_delete = models.CASCADE)
pub_datetime = models.DateTimeField() pub_datetime = models.DateTimeField(auto_now_add = True)
def __str__(self): def __str__(self):
return self.title return self.title
......
...@@ -5,7 +5,7 @@ from django.views.generic.detail import DetailView ...@@ -5,7 +5,7 @@ from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView from django.views.generic.edit import CreateView, UpdateView
def forum(request): def forum(request):
posts = ForumPost.objects.all() posts = ForumPost.objects.all().order_by('-pub_datetime')
replies = Reply.objects.all() replies = Reply.objects.all()
context = { context = {
'forumposts':posts, 'forumposts':posts,
......
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