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