PageRenderTime 31ms CodeModel.GetById 28ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/regressiontests/views/models.py

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