跳过在web2py中输入注册电子邮件

2024-05-27 11:18:09 发布

您现在位置:Python中文网/ 问答频道 /正文

我是web2py的新手,我正在尝试注册一个没有电子邮件地址的用户(reddit风格的登录),但是我不能跳过auth\u user中的email字段,我尝试了这些,因为它们看起来很直观

 auth.settings.registration_requires_email = False 

 auth.define_tables(username=True, signature=False,email=False)

不管他们怎么说都不存在,谢谢你的帮助。你知道吗


Tags: 用户authfalsesettings风格电子邮件email地址
2条回答

来自谷歌集团:

def user():
    if request.args(0) == 'register':
        for field in ['first_name', 'last_name', 'email']:
            db.auth_user[field].readable = db.auth_user[field].writable = False
    return dict(form=auth())

上面更改了中的user()函数默认.py控制器,所以它只是在注册表中隐藏姓名和电子邮件字段(但在配置文件表单中保持可见,以便以后可以根据需要填写)。你知道吗

下面是我为Customizing Auth找到的一个链接,它解释了如何准确地执行您想要的操作,即使用用户名而不是电子邮件地址进行身份验证。你知道吗

If you add a field called "username", it will be used in place of "email" for login. If you do, you will need to add a validator as well:

auth_table.username.requires = IS_NOT_IN_DB(db, auth_table.username)

所以看起来您必须利用链接中讨论的define_tables()函数。希望这有帮助!你知道吗

相关问题 更多 >

    热门问题