I know a lot of questions were around that topic, but I still cannot understand why in my case it's not working. I have the function on my views.py
@csrf_exempt
def index(request):
if request.method == 'POST':
form = MessageForm(request.POST)
if form.is_valid():
print("success")
messages.success(request, 'Form submitted successfully.')
else:
print("error")
messages.error(request, 'Error submitting the form.')
return render(request, 'index.html', {'form': form, 'messages': messages.get_messages(request)})
return render(request, 'index.html')
and I want that in my form on HTML will appear proper message on case if submit was succeed or no
{% if messages %}
{% for message in messages %}
<span class="{{ message.tags }}-django-color">{{ message }}</span>
{% endfor %}
{% endif %}
As result, I have on logs of WSGI (i'm hosting everything on apache) that succeed or error message, BUT on my HTML form it's not appearing. What Im doing wrong?
P.S. I have as described enabled INSTALLED_APPS, MIDDLEWARE and TEMPLATES in settings.py file
Thanks in advance, what I have miss