[英]Implement dummy registration with Django
I'm using Django to develop the backend of my mobile app. 我正在使用Django开发我的移动应用程序的后端。 I noticed some app have an 'one tap registration" functionality. User can just tap a button and a user id is generated for him, he can upload his data to his account already. Later when he has time, he can update info like username, password or email.
我注意到有些应用程序具有“一键注册”功能。用户只需轻按一个按钮,就会为他生成一个用户ID,他可以将其数据上传到他的帐户中。稍后,如果有时间,他可以更新用户名等信息,密码或电子邮件。
I'm wondering how can I do this with Django, I check django-user-accounts or the native Django.contrib.auth, but it seems they always require username or email at first. 我想知道如何使用Django,我检查了django-user-accounts或本机Django.contrib.auth,但看来他们一开始总是需要用户名或电子邮件。
If you are planning on using django.contrib.auth
, you can write your own custom user model in Django 1.5. 如果您打算使用
django.contrib.auth
,则可以在Django 1.5中编写自己的自定义用户模型 。 The example listed in the docs would work for your use-case. 文档中列出的示例适用于您的用例。
You don't need to extend AbstractBaseUser
, but if you do, it expects a USERNAME_FIELD
value. 您不需要扩展
AbstractBaseUser
,但是如果您这样做,它将需要USERNAME_FIELD
值。 Alternatively you can use any kind of model you want, but without a USERNAME_FIELD
convenient methods like login()
and logout()
and authenticate()
may break. 另外,您可以使用任何所需的模型,但是如果没有
USERNAME_FIELD
方便的方法(例如login()
和logout()
以及authenticate()
可能会中断。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.