2016-11-19 110 views
2

晚上好,我正在使用django註冊Web應用程序;通過使用這個,具有默認django註冊的表單只有4個字段(用戶名,電子郵件,密碼,重複密碼)。如何將更多字段添加到此表單並將它們正確存儲在數據庫中?謝謝。額外的字段Django註冊表格

回答

0

我沒有使用Django註冊,但我發現了一個鏈接,可能對你有幫助。

所有你需要做的就是擴展類'RegistrationForm'並添加更多的字段。

事情是這樣的: forms.py

import from registration.forms import RegistrationForm 

class CustomRegistrationForm(RegistrationForm): 
    extra_field = forms.EmailField() 
    extra_field_2 ... 

然後,處理表單POST並保存這些細節。

http://django-registration.readthedocs.io/en/2.0.1/forms.html

相關問題