djangosnippets.org: Latest snippets tagged with 'message'https://djangosnippets.org/tags/message/2009-02-05T08:40:55.987704-06:00Temporary admin messages (MOTD)
2009-02-05T08:40:55.987704-06:00bthomashttps://djangosnippets.org/snippets/1310/<p>This small app can display messages to users after they login and before they get to the normal landing page. This can be useful for displaying maintenance notices, information on new features, or a one-day-sale on shoes.</p>
<p>To redirect to the MOTD view after login, change:</p>
<p><code><input type="hidden" name="next" value="{{ …</code></p>
Freely redistributableSeverity codes in user messages
2009-01-17T19:33:20.563357-06:00cconnellhttps://djangosnippets.org/snippets/1288/<p>This is the code for a template tag. Put this code in your template to render your messages:</p>
<pre><code>{% for message in messages %}
{% render_user_message message %}
{% endfor %}
</code></pre>
<p>When you're adding a message to the user's message set, follow these rules: If you want a message to …</p>
Freely redistributableMessage exception
2008-10-14T12:31:31.903374-05:00marinhohttps://djangosnippets.org/snippets/1143/<p>This exception is util when you want to raise an exception but want its message be shown as a message to the user, with no error 500 or 404 pages.</p>
<p>To use it, just append the middleware in the MIDDLEWARE_CLASSES setting and raises HttpMessage when necessary.</p>
Freely redistributableTemplatetag startswith + message tuned
2008-06-15T12:09:13.564668-05:00io_errorhttps://djangosnippets.org/snippets/806/<p>Template:</p>
<pre><code> `<div id="messageBox_{{ forloop.counter0 }}" style="border:1px solid #ccc;background-color:white" onclick="document.getElementById ('messageBox_{{ forloop.counter0 }}').style.display = 'none';">
{% ifstartswith message "#ok#" %}
<font color="green">
{% endifstartswith %}
{% ifstartswith message "#error#" %}
<font color="red">
{% endifstartswith %}
{{ message|cut:"#ok#"|cut:"#error#" }}
</font>
</div>`
</code></pre>
<p>In a view you can now do something like that:
<code>request.user.message_set.create(message="#ok#Hello …</code></p>
Freely redistributableFixedEmailMessage
2008-03-06T05:01:03.695132-06:00buriyhttps://djangosnippets.org/snippets/630/<p>Django EmailMessage class has no cc support and has bug in bcc support.</p>
<p>Core developers won't add cc support (see ticket http://code.djangoproject.com/ticket/5790),
and I don't want to wait half a year until they will realize they have a flaw that bcc recipients are sent to regular "to:" recipients and fix …</p>
Freely redistributableFlash Message Template Tag
2007-07-16T00:58:14.693819-05:00rtconnerhttps://djangosnippets.org/snippets/319/<p>Flash message add-on for Django. Uses sessions. Behavior is such that you set a flash message in a view. That message is stored in the sesssion. Then whenever it is that the message gets displayed, it is removed from the session (never to be heard from again)</p>
<p><strong>Installation:</strong></p>
<p>In your …</p>
Freely redistributable