mirror of
https://github.com/django/django.git
synced 2024-12-30 21:16:26 +00:00
2607fa9016
This (nearly) completes the work to isolate all the test modules from each other. This is now more important as importing models from another module will case PendingDeprecationWarnings if those modules are not in INSTALLED_APPS. The only remaining obvious dependencies are: - d.c.auth depends on d.c.admin (because of the is_admin flag to some views), but this is not so important and d.c.admin is in always_installed_apps - test_client_regress depends on test_client. Eventually these should become a single module, as the split serves no useful purpose.
58 lines
1.3 KiB
Python
58 lines
1.3 KiB
Python
"""
|
|
Regression tests for Django built-in views.
|
|
"""
|
|
|
|
from django.db import models
|
|
from django.utils.encoding import python_2_unicode_compatible
|
|
|
|
|
|
@python_2_unicode_compatible
|
|
class Author(models.Model):
|
|
name = models.CharField(max_length=100)
|
|
|
|
def __str__(self):
|
|
return self.name
|
|
|
|
def get_absolute_url(self):
|
|
return '/authors/%s/' % self.id
|
|
|
|
|
|
@python_2_unicode_compatible
|
|
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).
|
|
"""
|
|
title = models.CharField(max_length=100)
|
|
slug = models.SlugField()
|
|
author = models.ForeignKey(Author)
|
|
|
|
class Meta:
|
|
abstract = True
|
|
|
|
def __str__(self):
|
|
return self.title
|
|
|
|
|
|
class Article(BaseArticle):
|
|
date_created = models.DateTimeField()
|
|
|
|
|
|
class UrlArticle(BaseArticle):
|
|
"""
|
|
An Article class with a get_absolute_url defined.
|
|
"""
|
|
date_created = models.DateTimeField()
|
|
|
|
def get_absolute_url(self):
|
|
return '/urlarticles/%s/' % self.slug
|
|
get_absolute_url.purge = True
|
|
|
|
|
|
class DateArticle(BaseArticle):
|
|
"""
|
|
An article Model with a DateField instead of DateTimeField,
|
|
for testing #7602
|
|
"""
|
|
date_created = models.DateField()
|