2007-09-17 22:48:33 +08:00
|
|
|
"""
|
2008-07-19 03:45:00 +08:00
|
|
|
Regression tests for Django built-in views.
|
2007-09-17 22:48:33 +08:00
|
|
|
"""
|
|
|
|
|
|
|
|
from django.db import models
|
|
|
|
|
|
|
|
class Author(models.Model):
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return self.name
|
|
|
|
|
|
|
|
def get_absolute_url(self):
|
|
|
|
return '/views/authors/%s/' % self.id
|
|
|
|
|
2008-07-19 03:45:00 +08:00
|
|
|
class BaseArticle(models.Model):
|
|
|
|
"""
|
|
|
|
An abstract article Model so that we can create article models with and
|
|
|
|
without a get_absolute_url method (for create_update generic views tests).
|
|
|
|
"""
|
2007-09-17 22:48:33 +08:00
|
|
|
title = models.CharField(max_length=100)
|
2007-09-19 21:26:56 +08:00
|
|
|
slug = models.SlugField()
|
2007-09-17 22:48:33 +08:00
|
|
|
author = models.ForeignKey(Author)
|
2007-09-19 21:26:56 +08:00
|
|
|
date_created = models.DateTimeField()
|
2008-07-19 03:45:00 +08:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
abstract = True
|
|
|
|
|
2007-09-17 22:48:33 +08:00
|
|
|
def __unicode__(self):
|
|
|
|
return self.title
|
|
|
|
|
2008-07-19 03:45:00 +08:00
|
|
|
class Article(BaseArticle):
|
|
|
|
pass
|
|
|
|
|
|
|
|
class UrlArticle(BaseArticle):
|
|
|
|
"""
|
|
|
|
An Article class with a get_absolute_url defined.
|
|
|
|
"""
|
|
|
|
def get_absolute_url(self):
|
|
|
|
return '/urlarticles/%s/' % self.slug
|