2
0

models.py 631 B

123456789101112131415161718192021222324252627
  1. from django.db import models
  2. from django.utils.encoding import python_2_unicode_compatible
  3. @python_2_unicode_compatible
  4. class Entry(models.Model):
  5. title = models.CharField(max_length=200)
  6. updated = models.DateTimeField()
  7. published = models.DateTimeField()
  8. class Meta:
  9. ordering = ('updated',)
  10. def __str__(self):
  11. return self.title
  12. def get_absolute_url(self):
  13. return "/blog/%s/" % self.pk
  14. @python_2_unicode_compatible
  15. class Article(models.Model):
  16. title = models.CharField(max_length=200)
  17. entry = models.ForeignKey(Entry)
  18. def __str__(self):
  19. return self.title