Questions tagged [django-messages]

Notification messages framework for Django

The messages framework

Quite commonly in web applications, you need to display a one-time notification message (also known as “flash message”) to the user after processing a form or some other types of user input.

For this, Django provides full support for cookie- and session-based messaging, for both anonymous and authenticated users. The messages framework allows you to temporarily store messages in one request and retrieve them for display in a subsequent request (usually the next one). Every message is tagged with a specific level that determines its priority (e.g., info, warning, or error).

155 questions
16
votes
2 answers

Django message template tag checking

I want to check whether the message tag are INFO ? How to check that in the template file? I tried this but it didn't work: {% if messages %}
    {% for message in messages %}
  • {% if message.tag == "INFO"…
Sibi
  • 47,472
  • 16
  • 95
  • 163
13
votes
2 answers

How to make a new line in django messages.error

I have a line of my code messages.error(request, ('ERROR: upload failed. Try again')) popping up a message in my template upload failed. Try again But I want to get a new line after the point, like: upload failed. Try again How do I get…
Tms91
  • 3,456
  • 6
  • 40
  • 74
13
votes
1 answer

Using django message framework with rest_framework

How can I have the django message framework work with the rest_framework? Here is my view @api_view(['GET', 'POST']) def myview(request): if request.method == 'GET': #return a Response object else: #process post data …
rjv
  • 6,058
  • 5
  • 27
  • 49
12
votes
6 answers

Show a successful message with Class Based Views

I, want show a successful message when a row is saved, using Django's messaging framework with Class Based Views, with code shown below, but don't show the message. Any help would be very much appreciated #views.py from django.views.generic import…
10
votes
2 answers

Django messages not showing after HttpResponseRedirect

Tried tonnes of stuff out there but none of them really helped. I have a URL for example: http://localhost:8000/user/edit-transaction/?object_id=23a959d0561711e59e36acd1b8679265&type=grossary which calls the below view: def…
Parag Tyagi
  • 8,780
  • 3
  • 42
  • 47
7
votes
2 answers

Redirect while passing message in django

I'm trying to run a redirect after I check to see if the user_settings exist for a user (if they don't exist - the user is taken to the form to input and save them). I want to redirect the user to the appropriate form and give them the message that…
Hanny
  • 580
  • 3
  • 16
  • 44
7
votes
1 answer

django allauth custom messages: Styling messages with html/css

Allauth's the messages are stored as text files in the templates directory by default and these look something like: {% load i18n %} {% blocktrans %}You cannot remove your primary e-mail address ({{email}}).{% endblocktrans %} These use django's…
Max Smith
  • 925
  • 1
  • 14
  • 25
6
votes
2 answers

Django: customizing the message after a successful form save

whenever I save a model in my Admin interface, it displays the usual "successfully saved message." However, I want to know if it's possible to customize this message because I have a situation where I want to warn the user about what he just saved…
chiurox
  • 1,549
  • 3
  • 18
  • 28
5
votes
2 answers

How can I add additional data to Django messages?

I'm trying to integrate this snippet into our Django project: It's just custom HTML and CSS for messages. The html looks like this:
Milano
  • 18,048
  • 37
  • 153
  • 353
4
votes
1 answer

Django messages framework - lack of i18n by default

By default django messages framework does not localize it's messages correctly. For example in admin interface As you can see all other things in admin panel are localized. The translation file exists. Here is my settings. INSTALLED_APPS = [ …
Andrey Nelubin
  • 3,084
  • 1
  • 20
  • 25
4
votes
3 answers

Django Admin Remove default save message

I have added this extra message in my model admin and basically I want to remove the default one. Is there someone that can help me to do this? My actual message: def save_model(self, request, obj, form, change): messages.Success(request,…
Cohen
  • 944
  • 3
  • 13
  • 40
4
votes
1 answer

How can I unit test django messages... with a HTTPResponseRedirect?

Just like this question... but harder. I have a view that redirects a user, and uses the Django messages framework to send them to the right page, and adds a message with code like that below: def new_comment(request,pid): post =…
user764357
4
votes
6 answers

Django: Remove duplicate messages from storage

I'm using messages to add flash messages to the template (just as you'd expect). The problem I have is that if you double click a link to a page that generates a message then the message appears twice. I am using the message to tell the user I have…
rockingskier
  • 9,066
  • 3
  • 40
  • 49
4
votes
2 answers

Making sure django model was properly saved

When saving a django model using it's save method is there any way to make sure nothing happened during save and send a message to the user? I was thinking of the message framework and try except block? try: model.save() add success message…
Apostolos
  • 7,763
  • 17
  • 80
  • 150
3
votes
1 answer

Django show message in every view

I want to show a message in every view in my Django project. Once a user has created an account, I send them an email asking them to verify their email and until they have verified their email address (by visiting a verify URL) I'll show the…
KerrM
  • 5,139
  • 3
  • 35
  • 60
1
2 3
10 11