In Django are updates of dict within a form class from a view persistent for all users? [duplicate]
I use Django 5.1.2
In order to clarify what my users need to do when my app serves them a form, I've added a dict to my forms called 'contents'. It contains a bunch of instructions for the template form.html:
class MyForm(forms.Form):
contents = {
'icon' : 'img/some-icon.png',
'title' : 'Description of form',
'message' : 'Some instruction for user',
'value' : 'text-label-of-the button',
}
class Meta:
fields = ('',)
Then in the view myview the form.contents are updated according to what the view does:
def myview(request):
if request.method == 'GET':
form = MyForm()
form.contents.update({
'icon' : 'img/wrong_red.png',
'title' : 'You did it wrong',
'color' : 'red',
'message' : 'Something user did wrong',
'value' : 'Cancel',
})
context = {'form' : form}
return render(request, 'form.html', context)
I run into the problem that the updated content for color persist throughout multiple requests from users. I would expect that update to a value in a class instance wouldn't persist. In my memory this used to be the case. As a work-around I could make a unique form class for each view, but this would result in a lot of repetitive code. What is the best fix for this issue?