I have an var containing all documents from mongoDB as an object. The way I set this is like this:
questions = Questions.objects.order_by('-openDate')
This works fine. When called, the objects show the attributes I expect. But now I want to add an attribute to it. Its not defined in the database, but I will set it base on some simple python code. To break it down:
- One of the fields is responses, which contain an userId and response.
By going through all responses:
for i in question.responses: if i.id == current_user: (Now the magic should happen)
Now comes what does not work. I want to add an attribute userResponded to the object. This way in the template I can simply ask if userResponded is true or false. To be clear, the userResponded should not be added to responses, but a new attribute.
Just to add to this, I already tried:
questions[0].test = 'test'
I expected it was now added to the first object in questions. However, this did not happen.
Please help, already stuck on this for way too long!