demo-HTML-over-WebSockets-i.../apps/back/models.py
Andros Fenollosa 901226c700 Update post
2021-03-12 00:09:19 +01:00

27 lines
694 B
Python

from django.db import models
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)
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)
def __str__(self):
return self.name