| 1 |
""" |
| 2 |
Regression tests for Django built-in views. |
| 3 |
""" |
| 4 |
|
| 5 |
from django.db import models |
| 6 |
|
| 7 |
|
| 8 |
class Author(models.Model): |
| 9 |
name = models.CharField(max_length=100) |
| 10 |
|
| 11 |
def get_absolute_url(self): |
| 12 |
return "/authors/%s/" % self.id |
| 13 |
|
| 14 |
|
| 15 |
class BaseArticle(models.Model): |
| 16 |
""" |
| 17 |
An abstract article Model so that we can create article models with and |
| 18 |
without a get_absolute_url method (for create_update generic views tests). |
| 19 |
""" |
| 20 |
|
| 21 |
title = models.CharField(max_length=100) |
| 22 |
slug = models.SlugField() |
| 23 |
author = models.ForeignKey(Author, models.CASCADE) |
| 24 |
|
| 25 |
class Meta: |
| 26 |
abstract = True |
| 27 |
|
| 28 |
|
| 29 |
class Article(BaseArticle): |
| 30 |
date_created = models.DateTimeField() |
| 31 |
|
| 32 |
|
| 33 |
class UrlArticle(BaseArticle): |
| 34 |
""" |
| 35 |
An Article class with a get_absolute_url defined. |
| 36 |
""" |
| 37 |
|
| 38 |
date_created = models.DateTimeField() |
| 39 |
|
| 40 |
def get_absolute_url(self): |
| 41 |
return "/urlarticles/%s/" % self.slug |
| 42 |
|
| 43 |
get_absolute_url.purge = True |
| 44 |
|
| 45 |
|
| 46 |
class DateArticle(BaseArticle): |
| 47 |
""" |
| 48 |
An article Model with a DateField instead of DateTimeField, |
| 49 |
for testing #7602 |
| 50 |
""" |
| 51 |
|
| 52 |
date_created = models.DateField() |