PageRenderTime 42ms CodeModel.GetById 19ms RepoModel.GetById 0ms 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
Possible License(s): BSD-3-Clause
  1. # coding: utf-8
  2. from django.db import models
  3. CHOICES = (
  4. (1, 'first'),
  5. (2, 'second'),
  6. )
  7. class Article(models.Model):
  8. headline = models.CharField(max_length=100, default='Default headline')
  9. pub_date = models.DateTimeField()
  10. status = models.IntegerField(blank=True, null=True, choices=CHOICES)
  11. misc_data = models.CharField(max_length=100, blank=True)
  12. article_text = models.TextField()
  13. class Meta:
  14. ordering = ('pub_date','headline')
  15. # A utf-8 verbose name (??ngstr??m's Articles) to test they are valid.
  16. verbose_name = "\xc3\x85ngstr\xc3\xb6m's Articles"
  17. def __unicode__(self):
  18. return self.headline
  19. class Movie(models.Model):
  20. #5218: Test models with non-default primary keys / AutoFields
  21. movie_id = models.AutoField(primary_key=True)
  22. name = models.CharField(max_length=60)
  23. class Party(models.Model):
  24. when = models.DateField(null=True)
  25. class Event(models.Model):
  26. when = models.DateTimeField()
  27. class Department(models.Model):
  28. id = models.PositiveIntegerField(primary_key=True)
  29. name = models.CharField(max_length=200)
  30. def __unicode__(self):
  31. return self.name
  32. class Worker(models.Model):
  33. department = models.ForeignKey(Department)
  34. name = models.CharField(max_length=200)
  35. def __unicode__(self):
  36. return self.name
  37. class BrokenUnicodeMethod(models.Model):
  38. name = models.CharField(max_length=7)
  39. def __unicode__(self):
  40. # Intentionally broken (trying to insert a unicode value into a str
  41. # object).
  42. return 'N??zov: %s' % self.name
  43. class NonAutoPK(models.Model):
  44. name = models.CharField(max_length=10, primary_key=True)