Commit 92dc8e17 authored by Stephanie Tullao's avatar Stephanie Tullao

Added Reply model in forum and added author fields to Post and Reply models

parent bb857699
File added
...@@ -4,7 +4,14 @@ from django.db import models ...@@ -4,7 +4,14 @@ from django.db import models
class Post(models.Model): class Post(models.Model):
post_title = models.CharField(max_length=150) post_title = models.CharField(max_length=150)
post_body = models.TextField() post_body = models.TextField()
pub_date = models.DateField(auto_now=True) pub_date = models.DateField(auto_now_add=True)
author = models.ForeignKey('homepage.WidgetUser', on_delete=models.CASCADE, related_name='posts')
def __str__(self): def __str__(self):
return '"{}" published {}'.format(self.post_title, self.pub_date) return '{}'.format(self.post_title)
\ No newline at end of file
class Reply(models.Model):
original_post = models.ForeignKey(Post, on_delete=models.CASCADE, related_name='replies')
reply_body = models.TextField()
pub_date = models.DateField(auto_now_add=True)
author = models.ForeignKey('homepage.WidgetUser', on_delete=models.CASCADE, related_name='replies')
\ No newline at end of file
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