我使用的是django註冊表單,我想添加一個額外的字段時間來註冊表單,並且我想將該字段保存到我的模型名爲profile.How can I do it.What會是我的看法?django註冊註冊表單中的其他字段
我的models.py
class Profile(models.Model):
age = models.IntegerField()
我使用的是django註冊表單,我想添加一個額外的字段時間來註冊表單,並且我想將該字段保存到我的模型名爲profile.How can I do it.What會是我的看法?django註冊註冊表單中的其他字段
我的models.py
class Profile(models.Model):
age = models.IntegerField()
你提到你有一個模型類,這是我的models.py
class Profile(models.Model):
age = models.IntegerField()
我認爲在這種情況下你可能會從這裏得到幫助: Python/Django django-registration add an extra field
from django.contrib.auth.models import User
class Profile(models.Model):
user = models.OneToOneField(User)
age = models.IntegerField()
更多細節:https://docs.djangoproject.com/en/dev/topics/auth/customizing/#extending-the-existing-user-model
我想,它可能會幫助你:http://stackoverflow.com/questions/14726725/python-django-django-registration-add-an- extra-field – hizbul25
@hizbul謝謝你的回答。你知道如何驗證自定義字段嗎? – Thameem
如果您從中得到任何幫助,您可以接受我的答案並投票。謝謝 – hizbul25