在我的网站上,可以通过以下方式登录:
我在哪里使用系统内置的 django 用户和 python 社交身份验证。
问题:
假设我创建了以下帐户:
用户名:losimonassi 电子邮件:lorenzosimonassi@gmail.com
然后,当我尝试使用我的 gmail (lorenzosimonassi@gmail.com) 登录时,python social auth 会使用相同的电子邮件创建另一个用户。因此,当我尝试使用我的电子邮件登录时,身份验证系统会发现两个类似的电子邮件,这会引发错误。
我试图找到一种方法,当用户尝试使用 gmail 登录时,会根据数据库检查他的电子邮件,如果它已经存在,则通过重定向和警报消息停止进程(我认为可以通过中间件)。
但是当然对DB的检查应该只对其他后端用户和普通用户进行检查,以免阻塞自己的登录。
我不想关联帐户。
设置.py
SOCIAL_AUTH_PIPELINE = (
'social.pipeline.social_auth.social_details',
'social.pipeline.social_auth.social_uid',
'social.pipeline.social_auth.auth_allowed',
'social.pipeline.social_auth.social_user',
'social.pipeline.user.get_username',
'social.pipeline.user.create_user',
#'social.pipeline.social_auth.associate_user',
#'social.pipeline.social_auth.load_extra_data',
'social.pipeline.user.user_details'
)
Run Code Online (Sandbox Code Playgroud)
为了练习我学到的东西,我开始了一个关于房地产网站的django项目.
下一步是构建搜索页面,用户可以选择multiple filters,对于为例,number of rooms,baths,area,city...
在我读的书中,我使用了搜索引擎(带有django haystack的Sorl),所以我想知道是否应该使用它来过滤数据库上的用户条件,或者我是否应该只使用djando查询来保持简单ifs.
你有什么建议我的?
django ×2