开发者

how can I limit to display a message only upon the login

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.


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 %}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜