2007-09-17 14:48:33 +00:00
|
|
|
"""
|
2008-07-18 19:45:00 +00:00
|
|
|
Regression tests for Django built-in views.
|
2007-09-17 14:48:33 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
from django.db import models
|
|
|
|
|
2013-11-02 21:34:05 +00:00
|
|
|
|
2007-09-17 14:48:33 +00:00
|
|
|
class Author(models.Model):
|
|
|
|
name = models.CharField(max_length=100)
|
|
|
|
|
|
|
|
def get_absolute_url(self):
|
2014-01-14 15:43:27 +00:00
|
|
|
return "/authors/%s/" % self.id
|
2007-09-17 14:48:33 +00:00
|
|
|
|
2013-11-02 21:34:05 +00:00
|
|
|
|
2008-07-18 19:45:00 +00: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).
|
|
|
|
"""
|
2022-02-03 19:24:19 +00:00
|
|
|
|
2007-09-17 14:48:33 +00:00
|
|
|
title = models.CharField(max_length=100)
|
2007-09-19 13:26:56 +00:00
|
|
|
slug = models.SlugField()
|
2015-07-22 14:43:21 +00:00
|
|
|
author = models.ForeignKey(Author, models.CASCADE)
|
2008-07-18 19:45:00 +00:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
abstract = True
|
|
|
|
|
2013-11-02 21:34:05 +00:00
|
|
|
|
2008-07-18 19:45:00 +00:00
|
|
|
class Article(BaseArticle):
|
2008-08-23 04:46:33 +00:00
|
|
|
date_created = models.DateTimeField()
|
2008-07-18 19:45:00 +00:00
|
|
|
|
2013-11-02 21:34:05 +00:00
|
|
|
|
2008-07-18 19:45:00 +00:00
|
|
|
class UrlArticle(BaseArticle):
|
|
|
|
"""
|
|
|
|
An Article class with a get_absolute_url defined.
|
|
|
|
"""
|
2022-02-03 19:24:19 +00:00
|
|
|
|
2008-08-23 04:46:33 +00:00
|
|
|
date_created = models.DateTimeField()
|
|
|
|
|
2008-07-18 19:45:00 +00:00
|
|
|
def get_absolute_url(self):
|
|
|
|
return "/urlarticles/%s/" % self.slug
|
2022-02-03 19:24:19 +00:00
|
|
|
|
2010-03-12 14:36:39 +00:00
|
|
|
get_absolute_url.purge = True
|
2008-08-23 04:46:33 +00:00
|
|
|
|
2013-11-02 21:34:05 +00:00
|
|
|
|
2008-08-23 04:46:33 +00:00
|
|
|
class DateArticle(BaseArticle):
|
|
|
|
"""
|
|
|
|
An article Model with a DateField instead of DateTimeField,
|
|
|
|
for testing #7602
|
|
|
|
"""
|
2022-02-03 19:24:19 +00:00
|
|
|
|
2008-08-23 04:46:33 +00:00
|
|
|
date_created = models.DateField()
|