检查用户是否首次登录而不使用django-allauth [英] Check if the user has logged in for the first time without using django-allauth

查看:96
本文介绍了检查用户是否首次登录而不使用django-allauth的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里发现了很多关于同一主题的问题,但是它们有一个共同点,即Django-allauth。但是我的项目使用djoser。我希望用户仅在首次登录时才向其个人资料添加一些其他信息。
我不能使用

I have found a lot of questions here asking about the same topic but they all have one thing in common, i.e. Django-allauth. But my project uses djoser. I want users to add some additional information to their profile only when they log in for the first time. I can not use the comparison of

user.last_login == user.date_joined

当我登录上次登录日期时,我希望用户登录以便他们进行更改。

as when I log in the last login date changes, and I want the user to log in so they can make the changes.

我正在使用Django 1.7和 djoser 进行登录

I am using Django 1.7 and djoser for the login and authentication purpose.

推荐答案

您只需添加一个新的 BooleanField (例如,将 is_previously_logged_in 命名为 default = False 到您的个人资料模型,并检查其是否仍为 False 。然后,您可以将其设置为 True ,这样就不会两次向用户显示个人资料信息。

You can simply add a new BooleanField (say, named is_previously_logged_in) with default=False to your profile model and check if it is still False at every login. You can then set it to True so that you don't show the profile information to the user twice.

这篇关于检查用户是否首次登录而不使用django-allauth的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆