我在Django 1.6中扩展了User对象并添加了一些额外的字段。我有一个表单,允许用户将他们的用户名和irc名称添加到他们的用户对象。但是当我使用表单保存时,信息没有被提交到数据库(没有被保存)。我没有任何错误,表格的帖子是200 ok。
class AccountForm(ModelForm):
class Meta:
model = Employee
def __init__(self, *args, **kwargs):
super(AccountForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_class = 'form-horizontal'
self.helper.label_class = 'col-lg-2 control-label'
self.helper.field_class = 'col-lg-4'
self.helper.layout = Layout(
Fieldset('Account Modify',
'irc_name',
'forum_username',
),
FormActions(
Submit('submit', 'Submit', css_class='btn-primary')
)
)
class Employee(AbstractUser):
irc_name = models.CharField(max_length="25")
forum_username = models.CharField(max_length="25")
class AccountModify(LoginRequiredMixin, UpdateView):
model = Employee
form_class = AccountForm
template_name = 'bot_data/account_modify.html'
success_url = '/'