mirror of
https://github.com/django/django.git
synced 2024-12-25 18:46:22 +00:00
7997133a3d
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7952 bcc190cf-cafb-0310-a4f2-bffc1f526a37
41 lines
961 B
Python
41 lines
961 B
Python
"""
|
|
Regression tests for Django built-in views.
|
|
"""
|
|
|
|
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
|
|
|
|
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)
|
|
date_created = models.DateTimeField()
|
|
|
|
class Meta:
|
|
abstract = True
|
|
|
|
def __unicode__(self):
|
|
return self.title
|
|
|
|
class Article(BaseArticle):
|
|
pass
|
|
|
|
class UrlArticle(BaseArticle):
|
|
"""
|
|
An Article class with a get_absolute_url defined.
|
|
"""
|
|
def get_absolute_url(self):
|
|
return '/urlarticles/%s/' % self.slug
|