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)
|
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):
|
2008-08-23 12:46:33 +08:00
|
|
|
date_created = models.DateTimeField()
|
2008-07-19 03:45:00 +08:00
|
|
|
|
|
|
|
class UrlArticle(BaseArticle):
|
|
|
|
"""
|
|
|
|
An Article class with a get_absolute_url defined.
|
|
|
|
"""
|
2008-08-23 12:46:33 +08:00
|
|
|
date_created = models.DateTimeField()
|
|
|
|
|
2008-07-19 03:45:00 +08:00
|
|
|
def get_absolute_url(self):
|
|
|
|
return '/urlarticles/%s/' % self.slug
|
2008-08-23 12:46:33 +08:00
|
|
|
|
|
|
|
class DateArticle(BaseArticle):
|
|
|
|
"""
|
|
|
|
An article Model with a DateField instead of DateTimeField,
|
|
|
|
for testing #7602
|
|
|
|
"""
|
|
|
|
date_created = models.DateField()
|