2013-02-10 16:15:49 +01:00
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2010-11-04 17:03:05 +01:00
|
|
|
from django.db import models
|
2012-08-12 12:32:08 +02:00
|
|
|
from django.utils.encoding import python_2_unicode_compatible
|
2010-11-04 17:03:05 +01:00
|
|
|
|
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
@python_2_unicode_compatible
|
2010-11-04 17:03:05 +01:00
|
|
|
class Article(models.Model):
|
|
|
|
title = models.CharField(max_length=100)
|
|
|
|
pub_date = models.DateField()
|
|
|
|
|
|
|
|
categories = models.ManyToManyField("Category", related_name="articles")
|
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
def __str__(self):
|
2010-11-04 17:03:05 +01:00
|
|
|
return self.title
|
|
|
|
|
2013-11-03 05:36:09 +01:00
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
@python_2_unicode_compatible
|
2010-11-04 17:03:05 +01:00
|
|
|
class Comment(models.Model):
|
|
|
|
article = models.ForeignKey(Article, related_name="comments")
|
|
|
|
text = models.TextField()
|
|
|
|
pub_date = models.DateField()
|
|
|
|
approval_date = models.DateField(null=True)
|
|
|
|
|
2012-08-12 12:32:08 +02:00
|
|
|
def __str__(self):
|
2010-11-04 17:03:05 +01:00
|
|
|
return 'Comment to %s (%s)' % (self.article.title, self.pub_date)
|
|
|
|
|
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)
|