I have a template which is just a simple list of objects, and I would like to show the current user's rating for each object next to that object. Here are the relevant models:
class Problem(models.Model):
question = models.TextField()
answer = models.TextField()
topic = models.ForeignKey(Topic)
class Attempt(models.Model):
user = models.ForeignKey(User)
problem = models.ForeignKey(Problem)
confidence = models.CharField(max_length=10)
date = models.DateTimeField(auto_now=True)
So the objects are 'problems' (displayed in the list just as their id) and the ratings are 'confidences'. And my template currently lists the problems for a given topic, and I would like to have the current user's confidence (if it exists) for each problem next to that problem.
Any ideas for how I can query for this and send it to / display it in the template? Thanks in advance for your help!
edit: I can alter the models if necessary. The attempts model is only for this, so it could be replaced entirely.