我在这里发现了很多关于相同主题的问题,但它们都有一个共同点,即Django-allauth。 但我的项目使用djoser。 我希望用户只有在第一次登录时才能在其个人资料中添加一些其他信息。 我无法使用比较
user.last_login == user.date_joined当我登录上次登录日期发生变化时,我希望用户登录以便他们进行更改。
我使用Django 1.7和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_joinedas when I log in the last login date changes, and I want the user to log in so they can make the changes.
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.
更多推荐
发布评论