Add dummy data
This commit is contained in:
@@ -1,3 +1,32 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
|
||||
STATUS = (
|
||||
(0,"Draft"),
|
||||
(1,"Publish")
|
||||
)
|
||||
|
||||
class Post(models.Model):
|
||||
title = models.CharField(max_length=200, unique=True)
|
||||
author = models.CharField(max_length=20)
|
||||
content = models.TextField()
|
||||
status = models.IntegerField(choices=STATUS, default=0)
|
||||
created_on = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
class Meta:
|
||||
ordering = ['-created_on']
|
||||
|
||||
def __str__(self):
|
||||
return self.title
|
||||
|
||||
class Comment(models.Model):
|
||||
name = models.CharField(max_length=20)
|
||||
body = models.CharField(max_length=128)
|
||||
post = models.ForeignKey(Post, on_delete= models.CASCADE)
|
||||
created_on = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
class Meta:
|
||||
ordering = ['-created_on']
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
Reference in New Issue
Block a user