2013-02-10 15:15:49 +00:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
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
|
2012-08-12 10:32:08 +00:00
|
|
|
from django.utils.encoding import python_2_unicode_compatible
|
2010-11-04 16:03:05 +00:00
|
|
|
|
|
|
|
|
2012-08-12 10:32:08 +00:00
|
|
|
@python_2_unicode_compatible
|
2010-11-04 16:03:05 +00:00
|
|
|
class Article(models.Model):
|
|
|
|
title = models.CharField(max_length=100)
|
|
|
|
pub_date = models.DateField()
|
2015-10-13 18:25:06 +00:00
|
|
|
pub_datetime = models.DateTimeField(default=timezone.now())
|
2010-11-04 16:03:05 +00:00
|
|
|
|
|
|
|
categories = models.ManyToManyField("Category", related_name="articles")
|
|
|
|
|
2012-08-12 10:32:08 +00:00
|
|
|
def __str__(self):
|
2010-11-04 16:03:05 +00:00
|
|
|
return self.title
|
|
|
|
|
2013-11-03 04:36:09 +00:00
|
|
|
|
2012-08-12 10:32:08 +00:00
|
|
|
@python_2_unicode_compatible
|
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)
|
|
|
|
|
2012-08-12 10:32:08 +00:00
|
|
|
def __str__(self):
|
2010-11-04 16:03:05 +00:00
|
|
|
return 'Comment to %s (%s)' % (self.article.title, self.pub_date)
|
|
|
|
|
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)
|