Q:

Set the data in render method after pre-declaration in Django

I have declared the variable as given below:
response = render( request, 'authme/login.html', {} )

At some point of time, I need to set the temporary cookie and pass the value of temporary cookie in the view.
I tried the following ways to set the data as given below:

response['message'] = "Login Failed: Please try again"
response.message = "Login Failed: Please try again"

Can anyone suggest how can I set the message part using variable "response", in the same way, How do we use for setting cookie, PFB:
response.set_cookie('message','Login Failed: Please try again')

So that it is equivalent to this line of statement:
response = render( request, 'authme/login.html', {"message":"Login Failed: Please try again"})

A:

Please refer to Django messages framework, you can pass messages from views:
messages.error(request, 'Login Failed')
messages.success(request, 'Successfully Logged in.'

And you can use these messages using Jinja2 in your HTML:
{% if messages %}
<ul class="messages">
    {% for message in messages %}
    <li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li>
    {% endfor %}
</ul>
{% endif %}

