models.py 753 B

123456789101112131415161718192021222324252627282930
  1. """Models for django-nose test application.
  2. Based on the Django tutorial:
  3. https://docs.djangoproject.com/en/1.8/intro/tutorial01/
  4. """
  5. from django.db import models
  6. class Question(models.Model):
  7. """A poll question."""
  8. question_text = models.CharField(max_length=200)
  9. pub_date = models.DateTimeField('date published')
  10. def __str__(self):
  11. """Return string representation."""
  12. return self.question_text
  13. class Choice(models.Model):
  14. """A poll answer."""
  15. question = models.ForeignKey(Question, on_delete=models.CASCADE)
  16. choice_text = models.CharField(max_length=200)
  17. votes = models.IntegerField(default=0)
  18. def __str__(self):
  19. """Return string representation."""
  20. return self.choice_text