开发者

"first time here?" message with django

Im writing an app that will display the register view depending if is first time visitor.

What and How is 开发者_C百科the better way to do this with Django?

thxs.


Use sessions: https://docs.djangoproject.com/en/1.8/topics/http/sessions/

And then do something like:

def my_view(request, *args, **kwargs):
    if request.session.get('visited', False):
        # response without the welcome message
    else:
        request.session['visited'] = True
        # response with the welcome message

For session-related settings (e.g. expiration), see https://docs.djangoproject.com/en/1.8/topics/http/sessions/#browser-length-sessions-vs-persistent-sessions

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜