Guest User

Untitled

a guest
May 21st, 2018
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. class Topic(models.Model):
  2. """A topic the user is learning about."""
  3. text = models.CharField(max_length=200)
  4. date_added = models.DateTimeField(auto_now_add=True)
  5. owner = models.ForeignKey(User)
  6.  
  7. def __str__(self):
  8. """Return a string representation of the model."""
  9. return self.text
  10.  
  11. In [21]: Topic.objects.create(text='Celery', owner_id=1)
  12. Out[21]: <Topic: Celery>
  13. In [34]: celery = Topic.objects.get(pk=22)
  14. In [35]: isinstance(celery, Topic)
  15. Out[35]: True
Add Comment
Please, Sign In to add comment