/tests/regressiontests/modeladmin/models.py
Python | 42 lines | 33 code | 8 blank | 1 comment | 0 complexity | 2684a61dc73b0a8b128369e38a71b908 MD5 | raw file
1# coding: utf-8 2from datetime import date 3 4from django.db import models 5from django.contrib.auth.models import User 6 7class Band(models.Model): 8 name = models.CharField(max_length=100) 9 bio = models.TextField() 10 sign_date = models.DateField() 11 12 class Meta: 13 ordering = ('name',) 14 15 def __unicode__(self): 16 return self.name 17 18class Concert(models.Model): 19 main_band = models.ForeignKey(Band, related_name='main_concerts') 20 opening_band = models.ForeignKey(Band, related_name='opening_concerts', 21 blank=True) 22 day = models.CharField(max_length=3, choices=((1, 'Fri'), (2, 'Sat'))) 23 transport = models.CharField(max_length=100, choices=( 24 (1, 'Plane'), 25 (2, 'Train'), 26 (3, 'Bus') 27 ), blank=True) 28 29class ValidationTestModel(models.Model): 30 name = models.CharField(max_length=100) 31 slug = models.SlugField() 32 users = models.ManyToManyField(User) 33 state = models.CharField(max_length=2, choices=(("CO", "Colorado"), ("WA", "Washington"))) 34 is_active = models.BooleanField() 35 pub_date = models.DateTimeField() 36 band = models.ForeignKey(Band) 37 38 def decade_published_in(self): 39 return self.pub_date.strftime('%Y')[:3] + "0's" 40 41class ValidationTestInlineModel(models.Model): 42 parent = models.ForeignKey(ValidationTestModel)