2010-11-04 16:03:05 +00:00
|
|
|
from django.db import models
|
2015-10-13 18:25:06 +00:00
|
|
|
from django.utils import timezone
|
2010-11-04 16:03:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Article(models.Model):
|
|
|
|
title = models.CharField(max_length=100)
|
|
|
|
pub_date = models.DateField()
|
2020-01-18 19:07:25 +00:00
|
|
|
pub_datetime = models.DateTimeField(default=timezone.now)
|
2010-11-04 16:03:05 +00:00
|
|
|
|
|
|
|
categories = models.ManyToManyField("Category", related_name="articles")
|
|
|
|
|
2013-11-03 04:36:09 +00:00
|
|
|
|
2010-11-04 16:03:05 +00:00
|
|
|
class Comment(models.Model):
|
2015-07-22 14:43:21 +00:00
|
|
|
article = models.ForeignKey(Article, models.CASCADE, related_name="comments")
|
2010-11-04 16:03:05 +00:00
|
|
|
text = models.TextField()
|
|
|
|
pub_date = models.DateField()
|
|
|
|
approval_date = models.DateField(null=True)
|
|
|
|
|
2013-11-03 04:36:09 +00:00
|
|
|
|
2010-11-04 16:03:05 +00:00
|
|
|
class Category(models.Model):
|
|
|
|
name = models.CharField(max_length=255)
|