Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Topic(models.Model):
- """A topic the user is learning about."""
- text = models.CharField(max_length=200)
- date_added = models.DateTimeField(auto_now_add=True)
- owner = models.ForeignKey(User)
- def __str__(self):
- """Return a string representation of the model."""
- return self.text
- In [21]: Topic.objects.create(text='Celery', owner_id=1)
- Out[21]: <Topic: Celery>
- In [34]: celery = Topic.objects.get(pk=22)
- In [35]: isinstance(celery, Topic)
- Out[35]: True
Add Comment
Please, Sign In to add comment