0
在Django >= 1.5
,給定一個CustomUser
模型email
爲USERNAME_FIELD
並沒有其他REQUIRED_FIELDS
:使用Django註冊自定義用戶沒有明確的用戶名字段
# customapp.models.py
class CustomUser(AbstractBaseUser):
email = models.EmailField(verbose_name='email address',
max_length=255, unique=True, db_index=True,
)
USERNAME_FIELD = 'email'
...
什麼是使用django-registration
最簡單的方法,號稱是兼容與Custom User Models
,而不必實際上重寫所有內容?
據我已經得到作爲創造我自己的後端,包括:
- 自定義登記表(SANS
username
) - 更新網址,通過新的自定義登記表
- 繼承的基本視(刪除引用
username
)
現在,django-registration
AP的核心models.py
內p,我發現RegistrationProfile
有hardcoded參考方法create_inactive_user
和create_profile
中的username
。
有沒有辦法使用django-registration
這個Custom User Model
而不必修改核心registration
應用程序中的任何東西?
這看起來很有希望。考慮到'RegistrationProfile',你將如何處理我的'CustomManager'的'create_user(self,email,password = None)'方法[想通過'username'](https://bitbucket.org/ubernostrum/django-登記/ SRC/8f242e35ef7c004e035e54b4bb093c32bf77c29f /登記在默認=#CL-84/models.py?)?謝謝。 – bnjmn
定義你的create_user接受參數,如'create_user(self,username,email,password)'? – iMom0
我嘗試過,但它似乎導致其他地方的問題,如創建'django-admin.py createsuperuser'或任何其他地方的用戶創建'登記'之外。 – bnjmn