Messages in django

Messages library is used for to print the message on web page according your needs.

 

add this setting in you views.py

 

from django.contrib import messages

 

And this code for set the messages

 

messages.success(request, ‘Thanks for Register’)

 

Now add this code in any place where you want to show your mesaage

{% if messages %}
<ul class="messages">
{% for message in messages %}
<li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li>
{% endfor %}
</ul>
{% endif %}

 

Now run your website page and check the all changes.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s