On Wed, Jul 6, 2011 at 2:16 AM, Venkatraman S <venka...@gmail.com> wrote:
>
> I am showing messages using the messaging framework; so i check if there are
> any messages in my base.html (i.e, {% if messages %} ) and if yes i show the
> messages with suitable styling.
> Messages are being rendered fine and i do not have any problem with that.
>
> But i see that , accessing 'messages' is causing a db hit - i.e, the 'if
> clause above - is it possible to avoid this db hit?

Well, yes and no.

If you're using database backed storage, then no. The only way to
determine if there are messages or not is to query the database and
determine if there are messages. There's no magic mechanism here.

However, there are other message backends that don't require database
access. Django ships with a cookie-backed messages engine. Since the
message storage is a pluggable interface, it's also possible to build
a messages backend that stores in memcache, redis, or some other
non-database store. These don't require database access because they
don't store messages in the database. Whether they will work for your
situation is entirely up to your requirements.

Yours,
Russ Magee %-)

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

Reply via email to