"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
精彩评论