Using new messages framework within built-in admin ?

70 views
Skip to first unread message

Nicolas Steinmetz

unread,
May 21, 2010, 9:46:54 AM5/21/10
to Django users
Hi,

For some actions I made from the Django built-in admin, I would like
to improve the user experience with a better distinction between
sucess & error messages.

With Django 1.1.x, I used to use Model admin actions [1] with
statements like :

modeladmin.message_user(request, "%s successfully marked as
published." % message_bit)

With the new 1.2 version, I was about to use the messages framework
and the messages.success() / messages.error() shortcuts to provide a
better experience. I now have in my code :

messages.success(request, "%s successfully marked as published." %
message_bit)

So running my own admin/base.html file, I replaced the messages
section by the example provided in the doc [2] :

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

What happens is that messages.tags is empty.If I understand well the
doc, I should have an "error" or "success" tags for my error/success
messages.

What did I miss ? Or is it a bug ? Or the admin do not use yet the new
message framework ?

[1] http://docs.djangoproject.com/en/dev/ref/contrib/admin/actions/#actions-as-modeladmin-methods
[2] http://docs.djangoproject.com/en/1.2/ref/contrib/messages/#ref-contrib-messages

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Nicolas Steinmetz

unread,
May 27, 2010, 6:49:29 AM5/27/10
to Django users

rahul jain

unread,
Jan 3, 2011, 1:50:33 PM1/3/11
to django...@googlegroups.com
anyone on this ?

How to display error messages ?
Reply all
Reply to author
Forward
0 new messages