Commit 276424fd authored by Norberto Tadeo's avatar Norberto Tadeo 😔

added reply model, added author relationship to reply and post, changed views.py to display data

parent 525e556e
...@@ -2,7 +2,6 @@ from django.db import models ...@@ -2,7 +2,6 @@ from django.db import models
from homepage.models import WidgetUser from homepage.models import WidgetUser
class Post(models.Model): class Post(models.Model):
#Author = WidgetUser.objects.all()
post_title = models.CharField(max_length=50) post_title = models.CharField(max_length=50)
post_body = models.CharField(max_length=100000) post_body = models.CharField(max_length=100000)
pub_date = models.DateField(auto_now_add=True) pub_date = models.DateField(auto_now_add=True)
...@@ -17,10 +16,7 @@ class Reply(models.Model): ...@@ -17,10 +16,7 @@ class Reply(models.Model):
pub_date = models.DateField(auto_now_add=True) pub_date = models.DateField(auto_now_add=True)
author = models.ForeignKey(WidgetUser, null = True, on_delete=models.CASCADE, default ='Anonymous') author = models.ForeignKey(WidgetUser, null = True, on_delete=models.CASCADE, default ='Anonymous')
active = models.BooleanField(default=True) active = models.BooleanField(default=True)
#parent = models.ForeignKey('self', null=True,blank=True,related_name='replies')
#class Meta:
#ordering = ('pub_date')
def __str__(self): def __str__(self):
if len(self.reply_body) >= 50: if len(self.reply_body) >= 50:
return 'Reply to ({} | {}) by {} - {}... | {}'.format(self.post.post_title,self.post.pub_date, self.author, self.reply_body[0:50],self.pub_date) return 'Reply to ({} | {}) by {} - {}... | {}'.format(self.post.post_title,self.post.pub_date, self.author, self.reply_body[0:50],self.pub_date)
......
from django.shortcuts import render from django.shortcuts import render
from . import models from . import models
from asyncio.windows_events import NULL from asyncio.windows_events import NULL
# Create your views here.
from django.http import HttpResponse from django.http import HttpResponse
def displayForumPosts(request): def displayForumPosts(request):
......
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