PageRenderTime 44ms CodeModel.GetById 35ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/regressiontests/model_regress/models.py

https://code.google.com/p/mango-py/
Python | 59 lines | 39 code | 15 blank | 5 comment | 0 complexity | 2f5298076202a8720e38996223d45427 MD5 | raw file
 1# coding: utf-8
 2from django.db import models
 3
 4
 5CHOICES = (
 6    (1, 'first'),
 7    (2, 'second'),
 8)
 9
10class Article(models.Model):
11    headline = models.CharField(max_length=100, default='Default headline')
12    pub_date = models.DateTimeField()
13    status = models.IntegerField(blank=True, null=True, choices=CHOICES)
14    misc_data = models.CharField(max_length=100, blank=True)
15    article_text = models.TextField()
16
17    class Meta:
18        ordering = ('pub_date','headline')
19        # A utf-8 verbose name (??ngstr??m's Articles) to test they are valid.
20        verbose_name = "\xc3\x85ngstr\xc3\xb6m's Articles"
21
22    def __unicode__(self):
23        return self.headline
24
25class Movie(models.Model):
26    #5218: Test models with non-default primary keys / AutoFields
27    movie_id = models.AutoField(primary_key=True)
28    name = models.CharField(max_length=60)
29
30class Party(models.Model):
31    when = models.DateField(null=True)
32
33class Event(models.Model):
34    when = models.DateTimeField()
35
36class Department(models.Model):
37    id = models.PositiveIntegerField(primary_key=True)
38    name = models.CharField(max_length=200)
39
40    def __unicode__(self):
41        return self.name
42
43class Worker(models.Model):
44    department = models.ForeignKey(Department)
45    name = models.CharField(max_length=200)
46
47    def __unicode__(self):
48        return self.name
49
50class BrokenUnicodeMethod(models.Model):
51    name = models.CharField(max_length=7)
52
53    def __unicode__(self):
54        # Intentionally broken (trying to insert a unicode value into a str
55        # object).
56        return 'N??zov: %s' % self.name
57
58class NonAutoPK(models.Model):
59    name = models.CharField(max_length=10, primary_key=True)