Hi,
I have a model which holds the scores for answers to questions within questionnaries.
I’d like to group the scores for each project into a list of dictionaries i think. So that i can create some charts.
I’m running scores = ProjectScores.objects.filter(profile__user=profile.user)
to return all values.
And then I’m doing:
scores_across_all_projects = []
for score in scores:
if score.score:
scores_across_all_projects.append(score.score)
But this is returning just the set of scores [23,45,11,...]
Ideally i’d like to be ProjectName:ProjectName,"scores: 24,45,11
class ProjectScores(models.Model):
project = models.ForeignKey(Project, on_delete=models.CASCADE, blank=True)
profile = models.ForeignKey(Profile, on_delete=models.CASCADE, blank=True)
questionnaire = models.ForeignKey('ProjectQuestionnaire', on_delete=models.CASCADE, blank=True)
score = models.SmallIntegerField(blank=True, null=True)
def __str__(self):
return str(self.project)
class Meta:
verbose_name = "Project Score"
Thanks