class ArticleBase(models.Model):
title = models.CharField(max_length=32, db_index=True)
date_time = models.DateTimeField(auto_now=True, db_index=True)
text = models.TextField()
authors = models.ManyToManyField('Author')
class Meta:
abstract = True
ordering = ( '-date_time', )
class Article(ArticleBase):
pass
class NewestArticle(ArticleBase)
""" READ ONLY MODEL """
def save(self, **kwargs):
raise NotImplementedError
DROP TABLE app_newestarticle_authors;
DROP TABLE app_newestarticle;
CRETAE VIEW app_newestarticle AS SELECT * FROM app_article ORDER BY date_time DESC LIMIT 100;
CRETAE VIEW app_newestarticle_authors AS SELECT article_id newestarticle_id, author_id FROM app_article_authors;
Comments