0

Hi i am trying to show a message but the django message is not showing. The way i want to access this is if i send a webhook to a function in python for example. ill send a webhook post request using postman , and i will receive the messagepostman then it is working

But if i then go to my page it is not showingthis is when i go to my browser where the app is running

so my question is why is it working when i am using postman and not when using the browser, i also have a option to send the webhook request using a form on the app itself and ive added a refresh method as well but still nothing happpens.

is there a way to get a message on django if the python function is triggered with a webhook?

i am currently using 2 methods , both are working when using postman but neither works on the app itself

method 1

messages.add_message(request, messages.INFO, 'LONG was placed.')
    {% if messages %}
{% for message in messages %}
<div class = "alert alert-{{message.tags}}">{{message}}</div>
{% endfor %}
{% endif %}

and method 2

        storage = messages.get_messages(request)
        for message in storage:
            a=(message)
            print(a)
        storage.used = False
        context = {'a':a}
        return render(request,'crodlUSDT/syntax.html',context)
and then just calling it in my base.html {{a}}

i am new to coding in general but ive been struggling for days now so would appreciate any help, thanks

1 Answers1

0

use this method for views.py:

messages.info(request, "Your message")

after in HTML files:

{% if messages %}
    {% for message in messages %}
        <div class = "alert alert-{{message.tags}}">{{message}}</div>
    {% endfor %}
{% endif %}