所以我有一个表单向导工作得很好,但后来改变了两件事,现在收到一个InternalError
数据库错误。首先,我使用get_template_names
.
表格.py:
TEMPLATES = {'0': 'formtools/wizard/wizard_form.html',
'1': 'formtools/wizard/wizard_form.html',
'2': 'formtools/wizard/wizard_map.html'}
class CreateWizard(SessionWizardView):
get_template_names(self):
return [TEMPLATES[self.steps.current]]
其次,我添加FloatFields
到正在保存的模型和表单本身:
class Thing(models.Model):
....
latitude = models.FloatField()
longitude = models.FloatField()
....
class StepThreeForm(forms.Form):
....
latitude = forms.FloatField()
longitude = forms.FloatField()
....
我不确定我为什么会收到InternalError: current transaction is aborted, commands ignored until end of transaction block
. 这是回溯:
File "/myapp/lib/python2.7/django/core/handlers/base.py" in get_response
111. response = callback(request, *callback_args, **callback_kwargs)
File "/myapp/lib/python2.7/django/contrib/auth/decorators.py" in _wrapped_view
20. return view_func(request, *args, **kwargs)
File "/myapp/lib/python2.7/django/views/generic/base.py" in view
48. return self.dispatch(request, *args, **kwargs)
File "/myapp/lib/python2.7/django/contrib/formtools/wizard/views.py" in dispatch
223. response = super(WizardView, self).dispatch(request, *args, **kwargs)
File "/myapp/lib/python2.7/django/views/generic/base.py" in dispatch
69. return handler(request, *args, **kwargs)
File "/myapp/lib/python2.7/django/contrib/formtools/wizard/views.py" in post
286. return self.render_done(form, **kwargs)
File "/myapp/lib/python2.7/django/contrib/formtools/wizard/views.py" in render_done
328. done_response = self.done(final_form_list, **kwargs)
File "/myapp/myproject/myapp/forms.py" in done
82. instance.save()
File "/myapp/myproject/myapp/models.py" in save
112. super(Thing, self).save()
File "/myapp/lib/python2.7/django/db/models/base.py" in save
463. self.save_base(using=using, force_insert=force_insert, force_update=force_update)
File "/myapp/lib/python2.7/django/db/models/base.py" in save_base
551. result = manager._insert([self], fields=fields, return_id=update_pk, using=using, raw=raw)
File "/myapp/lib/python2.7/django/db/models/manager.py" in _insert
203. return insert_query(self.model, objs, fields, **kwargs)
File "/myapp/lib/python2.7/django/db/models/query.py" in insert_query
1593. return query.get_compiler(using=using).execute_sql(return_id)
File "/myapp/lib/python2.7/django/db/models/sql/compiler.py" in execute_sql
910. cursor.execute(sql, params)
Exception Type: InternalError at /
Exception Value: current transaction is aborted, commands ignored until end of transaction block
这些是我唯一更改的两件事,以及在向导的第 3 步添加模板。我无法弄清楚为什么这会改变我的向导的功能。你能帮我弄清楚为什么我现在收到这个错误吗?感谢您对这个令人困惑的问题的任何想法!
编辑:添加这些字段后,我通过南更新了我的架构。此外,我尝试使用DecimalField
而不是FloatField
,但仍然出现数据库错误。