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
|
|
|
|
|
2013-11-03 05:34:05 +08:00
|
|
|
|
2007-09-17 22:48:33 +08:00
|
|
|
class Author(models.Model):
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
|
|
|
|
def get_absolute_url(self):
|
2014-01-14 23:43:27 +08:00
|
|
|
return '/authors/%s/' % self.id
|
2007-09-17 22:48:33 +08:00
|
|
|
|
2013-11-03 05:34:05 +08:00
|
|
|
|
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()
|
2015-07-22 22:43:21 +08:00
|
|
|
author = models.ForeignKey(Author, models.CASCADE)
|
2008-07-19 03:45:00 +08:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
abstract = True
|
|
|
|
|
2013-11-03 05:34:05 +08:00
|
|
|
|
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
|
|
|
|
2013-11-03 05:34:05 +08:00
|
|
|
|
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
|
2010-03-12 22:36:39 +08:00
|
|
|
get_absolute_url.purge = True
|
2008-08-23 12:46:33 +08:00
|
|
|
|
2013-11-03 05:34:05 +08:00
|
|
|
|
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()
|