PageRenderTime 81ms CodeModel.GetById 40ms app.highlight 5ms RepoModel.GetById 35ms app.codeStats 0ms

/tests/regressiontests/admin_validation/models.py

https://code.google.com/p/mango-py/
Python | 55 lines | 31 code | 20 blank | 4 comment | 0 complexity | ed414cd51a872959950483d7ac4d72ad MD5 | raw file
 1"""
 2Tests of ModelAdmin validation logic.
 3"""
 4
 5from django.db import models
 6
 7
 8class Album(models.Model):
 9    title = models.CharField(max_length=150)
10
11
12class Song(models.Model):
13    title = models.CharField(max_length=150)
14    album = models.ForeignKey(Album)
15    original_release = models.DateField(editable=False)
16
17    class Meta:
18        ordering = ('title',)
19
20    def __unicode__(self):
21        return self.title
22
23    def readonly_method_on_model(self):
24        # does nothing
25        pass
26
27
28class TwoAlbumFKAndAnE(models.Model):
29    album1 = models.ForeignKey(Album, related_name="album1_set")
30    album2 = models.ForeignKey(Album, related_name="album2_set")
31    e = models.CharField(max_length=1)
32
33
34class Author(models.Model):
35    name = models.CharField(max_length=100)
36
37
38class Book(models.Model):
39    name = models.CharField(max_length=100)
40    subtitle = models.CharField(max_length=100)
41    price = models.FloatField()
42    authors = models.ManyToManyField(Author, through='AuthorsBooks')
43
44
45class AuthorsBooks(models.Model):
46    author = models.ForeignKey(Author)
47    book = models.ForeignKey(Book)
48
49
50class State(models.Model):
51    name = models.CharField(max_length=15)
52
53
54class City(models.Model):
55    state = models.ForeignKey(State)