PageRenderTime 23ms CodeModel.GetById 20ms RepoModel.GetById 0ms 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
Possible License(s): BSD-3-Clause
  1. """
  2. Tests of ModelAdmin validation logic.
  3. """
  4. from django.db import models
  5. class Album(models.Model):
  6. title = models.CharField(max_length=150)
  7. class Song(models.Model):
  8. title = models.CharField(max_length=150)
  9. album = models.ForeignKey(Album)
  10. original_release = models.DateField(editable=False)
  11. class Meta:
  12. ordering = ('title',)
  13. def __unicode__(self):
  14. return self.title
  15. def readonly_method_on_model(self):
  16. # does nothing
  17. pass
  18. class TwoAlbumFKAndAnE(models.Model):
  19. album1 = models.ForeignKey(Album, related_name="album1_set")
  20. album2 = models.ForeignKey(Album, related_name="album2_set")
  21. e = models.CharField(max_length=1)
  22. class Author(models.Model):
  23. name = models.CharField(max_length=100)
  24. class Book(models.Model):
  25. name = models.CharField(max_length=100)
  26. subtitle = models.CharField(max_length=100)
  27. price = models.FloatField()
  28. authors = models.ManyToManyField(Author, through='AuthorsBooks')
  29. class AuthorsBooks(models.Model):
  30. author = models.ForeignKey(Author)
  31. book = models.ForeignKey(Book)
  32. class State(models.Model):
  33. name = models.CharField(max_length=15)
  34. class City(models.Model):
  35. state = models.ForeignKey(State)