Created Reply model and Added author field in Post and Reply model.

parent 8f03eaf4
from django.db import models from django.db import models
from homepage.models import WidgetUser
# Create your models here. # Create your models here.
class Post(models.Model): class Post(models.Model):
post_title = models.CharField(max_length=50) post_title = models.CharField(max_length=50)
post_body = models.CharField(max_length=500) post_body = models.CharField(max_length=500)
pub_date = models.DateTimeField("date published") pub_date = models.DateTimeField("date published")
author = models.ForeignKey(WidgetUser, on_delete=models.CASCADE, default=1)
def __str__(self): def __str__(self):
return self.post_title return self.post_title
\ No newline at end of file
class Reply(models.Model):
post = models.ForeignKey(Post, on_delete=models.CASCADE, default=1)
reply_body = models.CharField(max_length=250)
pub_date = models.DateTimeField("date published")
author = models.ForeignKey(WidgetUser, on_delete=models.CASCADE, default=1)
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