PageRenderTime 37ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/modeltests/lookup/models.py

https://code.google.com/p/mango-py/
Python | 29 lines | 19 code | 5 blank | 5 comment | 0 complexity | 7e7b20eb236571fce9624fe55d0be830 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. """
  2. 7. The lookup API
  3. This demonstrates features of the database API.
  4. """
  5. from django.db import models, DEFAULT_DB_ALIAS, connection
  6. from django.conf import settings
  7. class Author(models.Model):
  8. name = models.CharField(max_length=100)
  9. class Meta:
  10. ordering = ('name', )
  11. class Article(models.Model):
  12. headline = models.CharField(max_length=100)
  13. pub_date = models.DateTimeField()
  14. author = models.ForeignKey(Author, blank=True, null=True)
  15. class Meta:
  16. ordering = ('-pub_date', 'headline')
  17. def __unicode__(self):
  18. return self.headline
  19. class Tag(models.Model):
  20. articles = models.ManyToManyField(Article)
  21. name = models.CharField(max_length=100)
  22. class Meta:
  23. ordering = ('name', )