0

Is there any way to recognize if the registered user is a recent user, such as registed a day ago from template?

I want to display "how my site works" banner for not logged in or a day of users.

Thanks

4

1 回答 1

1

添加上下文处理器。我在过去一小时内注册的用户的示例代码。

额外上下文.py

def extra_user_context(request):
    return {'is_recently_register': (datetime.today()-request.user.date_joined).seconds<3600 } if request.user.is_authenticated() else {}

索引.html

{% if is_recently_register %}BangGangOfFour{% endif %} 
于 2012-12-06T19:44:28.190 回答