关于python:MongoDBForm错误“ValueError:必须提供文档类”

MongoDBForm error “ValueError:A document class must be provided”

嗨,我正在用django框架和mongodb创建一个简单的注册表单。以下是我的观点:

1
2
3
4
class SignUpView(FormView):
    template_name='MnCApp/signup.html'
    form_class=EmployeeForm()
    succes_url='/success/'

以下是我的模型:

1
2
3
4
5
class Employee(Document):
    designation=StringField()
    department=StringField()
    emp_name=StringField(max_length=50)
    password=StringField(max_length=10)

下面是我的forms.py

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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时收到的跟踪值错误回溯:

File"C:\Program Files\Python35\lib\site-packages\django\core\handlers\exception.py" in inner
39. response = get_response(request)

File"C:\Program Files\Python35\lib\site-packages\django\core\handlers\base.py" in _get_response
187. response = self.process_exception_by_middleware(e, request)

File"C:\Program Files\Python35\lib\site-packages\django\core\handlers\base.py" in _get_response
185. response = wrapped_callback(request, *callback_args, **callback_kwargs)

File"C:\Program Files\Python35\lib\site-packages\django\views\generic\base.py" in view
68. return self.dispatch(request, *args, **kwargs)

File"C:\Program Files\Python35\lib\site-packages\django\views\generic\base.py" in dispatch
88. return handler(request, *args, **kwargs)

File"C:\Program Files\Python35\lib\site-packages\django\views\generic\edit.py" in get
174. return self.render_to_response(self.get_context_data())

File"C:\Program Files\Python35\lib\site-packages\django\views\generic\edit.py" in get_context_data
93. kwargs['form'] = self.get_form()

File"C:\Program Files\Python35\lib\site-packages\django\views\generic\edit.py" in get_form
45. return form_class(**self.get_form_kwargs())

File"C:\Program Files\Python35\lib\site-packages\mongodbforms\documents.py" in init
353. raise ValueError('A document class must be provided.')

Exception Type: ValueError at /signup/
Exception Value: A document class must be provided.

我找不到这个问题的根源。我对姜戈不熟悉,这是我的第一个项目。还有他们为蒙古人文档创建模型表单的其他方法吗??


我怀疑你的内部阶级应该叫Meta,而不是Meta