您好我正在使用django框架和mongodb创建一个简单的注册表单。以下是我的观点:
class SignUpView(FormView):
template_name='MnCApp/signup.html'
form_class=EmployeeForm()
succes_url='/success/'
以下是我的模特:
class Employee(Document):
designation=StringField()
department=StringField()
emp_name=StringField(max_length=50)
password=StringField(max_length=10)
以下是我的forms.py
class EmployeeForm(DocumentForm):
class meta:
desigs=(
('D','Director'),
('GM','General Manager'),
('AM','Assistant Manager'),
('A','Associates')
)
deptts=(
('HR','Human Resources'),
('IT','IT Support'),
('TT','Technical Team'),
('SM','Sales and Marketting'),
('SS','Support Staff')
)
document=Employee
fields='__all__'
widgets={
'designation':Select(choices=desigs),
'department':Select(choices=deptts)
}
以下是加载SignUpview时收到的追溯ValueError 回溯:
文件" C:\ Program Files \ Python35 \ lib \ site-packages \ django \ core \ handlers \ exception.py"在内心 39. response = get_response(request)
文件" C:\ Program Files \ Python35 \ lib \ site-packages \ django \ core \ handlers \ base.py"在_get_response中 187. response = self.process_exception_by_middleware(e,request)
文件" C:\ Program Files \ Python35 \ lib \ site-packages \ django \ core \ handlers \ base.py"在_get_response中 185. response = wrapped_callback(request,* callback_args,** callback_kwargs)
文件" C:\ Program Files \ Python35 \ lib \ site-packages \ django \ views \ generic \ base.py"在视野中 68.返回self.dispatch(request,* args,** kwargs)
文件" C:\ Program Files \ Python35 \ lib \ site-packages \ django \ views \ generic \ base.py"在发货 88.返回处理程序(request,* args,** kwargs)
文件" C:\ Program Files \ Python35 \ lib \ site-packages \ django \ views \ generic \ edit.py"在得到 174.返回self.render_to_response(self.get_context_data())
文件" C:\ Program Files \ Python35 \ lib \ site-packages \ django \ views \ generic \ edit.py"在get_context_data中 93. kwargs ['形式'] = self.get_form()
文件" C:\ Program Files \ Python35 \ lib \ site-packages \ django \ views \ generic \ edit.py"在get_form中 45.返回form_class(** self.get_form_kwargs())
文件" C:\ Program Files \ Python35 \ lib \ site-packages \ mongodbforms \ documents.py"在 init 353.引发ValueError('必须提供文档类。')
异常类型:/ signup /的ValueError 例外值:必须提供文档类。
我无法找到此问题的根源。我是django的新手,这是我的第一个项目。也是他们为mongo文档创建模型表单的另一种方法吗?
答案 0 :(得分:0)
我怀疑你的内部类应该被称为Meta
,而不是meta
。