File: models.py

package info (click to toggle)
python-django 3%3A5.2.5-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 61,236 kB
  • sloc: python: 361,585; javascript: 19,250; xml: 211; makefile: 182; sh: 28
file content (52 lines) | stat: -rw-r--r-- 1,114 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"""
Regression tests for Django built-in views.
"""

from django.db import models


class Author(models.Model):
    name = models.CharField(max_length=100)

    def get_absolute_url(self):
        return "/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, models.CASCADE)

    class Meta:
        abstract = True


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()