class Question(models.Model):
"""This class represents a question. It can have 2 or more options."""
created_on = models.DateTimeField(auto_now_add = 1)
title = models.CharField(max_length = 200)
slug = models.SlugField(unique = True, max_length = 200)
class Choice(models.Model):
"""This represents an answer to the Question, and has a foreignkey to it"""
question = models.ForeignKey(Question)
text = models.TextField()
total_votes = models.IntegerField(default = 0)
I want query last question and it’s choice Im try but can’t get last as form
to get the last item you can do something like:
and to get the choices:
To sum-up, this is how your view should look like:
and this is your template:
something like that!