Нема описа

models.py 779B

1234567891011121314151617181920212223242526
  1. from django.db import models
  2. from django.contrib.auth.models import User
  3. class Topic(models.Model):
  4. """A topic the user is learning about."""
  5. text = models.CharField(max_length=200)
  6. date_added = models.DateTimeField(auto_now_add=True)
  7. owner = models.ForeignKey(User)
  8. def __str__(self):
  9. """Return a string representation of the model."""
  10. return self.text
  11. class Entry(models.Model):
  12. """Something specific learned about a topic."""
  13. topic = models.ForeignKey(Topic)
  14. text = models.TextField()
  15. date_added = models.DateTimeField(auto_now_add=True)
  16. class Meta:
  17. verbose_name_plural = 'entries'
  18. def __str__(self):
  19. """Return a string representation of the model."""
  20. return self.text[:50] + "..."