models.py 543 B

12345678910111213141516171819202122
  1. """
  2. Comments may be attached to any object. See the comment documentation for
  3. more information.
  4. """
  5. from django.db import models
  6. from django.test import TestCase
  7. class Author(models.Model):
  8. first_name = models.CharField(max_length=30)
  9. last_name = models.CharField(max_length=30)
  10. def __str__(self):
  11. return '%s %s' % (self.first_name, self.last_name)
  12. class Article(models.Model):
  13. author = models.ForeignKey(Author)
  14. headline = models.CharField(max_length=100)
  15. def __str__(self):
  16. return self.headline