models.py 540 B

1234567891011121314151617181920212223242526
  1. # coding: utf-8
  2. from django.db import models
  3. from django.utils.encoding import python_2_unicode_compatible
  4. @python_2_unicode_compatible
  5. class Poet(models.Model):
  6. name = models.CharField(max_length=100)
  7. class Meta:
  8. app_label = 'formtools'
  9. def __str__(self):
  10. return self.name
  11. @python_2_unicode_compatible
  12. class Poem(models.Model):
  13. poet = models.ForeignKey(Poet)
  14. name = models.CharField(max_length=100)
  15. class Meta:
  16. app_label = 'formtools'
  17. def __str__(self):
  18. return self.name