我正在使用 Django 1.4 和酥脆的表格。这有一些问题。我正在查看示例,但仍然无法弄清楚。我有一个带有“pk”参数的示例,您可以在其中编辑请求的用户。但现在我需要进行自我编辑。编辑我自己的数据。
我得到了像 -
Failed lookup for key [form] in u ....
有很长很长的输出。我的表单已经构建,因为我将该表单放到其他视图中并且它工作正常。
这是我的看法
class ManagerProfileEditView(LoginRequiredMixin, TemplateView):
model = User
template_name = 'profile/edit.html'
form_class = ProfileEditForm
def get_success_url(self):
messages.success(self.request, _('Profile was edited'))
return reverse('manager:profile_edit')
在这里形成
class ProfileEditForm(forms.ModelForm):
class Meta:
model = User
field = ('email', 'first_name', 'last_name')
helper = FormHelper()
def __init__(self, *args, **kwargs):
super(ProfileEditForm, self).__init__(*args, **kwargs)
self.helper.form_class = 'form-horizontal'
self.helper.layout = Layout(
Field('email', 'first_name', 'last_name',
FormActions(
Submit('save_changes', _('Save changes'), css_class="btn btn-primary"),
Submit('cancel', _('Cancel')),
)
)
)
据我了解 prolly 应该放置我要“管理”的用户(就像“self.user”)
我希望你能理解我的问题
ps 模板中的输出为
{% crispy form %}