PageRenderTime 19ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/regressiontests/modeladmin/models.py

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