views:

40

answers:

1

I would like to learn how to limit a particular part of a template to be displayed upon the user login. E.g. the greeting message in the home page will be displayed once after the user's successful login but not again on the consecutive visit of the home page during the same session. I guess it could be possible by use of the HTTP_referrer. I will appreciate if someone can guide me by some examples.

+5  A: 

Check our django user messages. You can set a message via something like this (in your view):

request.user.message_set.create(message="Thanks for logging in!")

Then, display them (from the django docs):

{% if messages %}
<ul>
    {% for message in messages %}
    <li>{{ message }}</li>
    {% endfor %}
</ul>
{% endif %}
thornomad