我正在为我的车库店做一个业余爱好项目。我被引导到django-model-utils来获取我需要的东西。(我有串口数控机床,串口机床有两种流控方式)
我有一个父类SerialMachine (定义地址、波特率、通用RS-232定义)
然后我有了继承自SerialMachine的HardwareFlowControlMachine模型(定义了CTS/DTR/etc)
因此,当我将机器名放入表单(比如Machine001)中时,我有一个获取机器设置的函数。
def getMachineSettings(machine):
from src.apps.cnc.models import SerialMachine
machineSettings = SerialMachine.objects.get(machineName=machine).select_subclasses()
return machineSettings我得到了这个例外:
DatabaseError: no such column: cnc_hardwareflowcontrolmachine.serialmachine_ptr_id现在为了测试,我只在SoftwareFlowControlMachine中有一台机器(硬件中没有)
我想也许因为某种原因,HardwareFlowControlMachine至少需要一个对象。因此,当我转到/admin/并尝试将一台计算机添加到SoftwareFlowControlMachine或HardwareFlowControlMachine时,我得到了以下异常:
HardwareFlowControlMachine:
DatabaseError at /admin/cnc/hardwareflowcontrolmachine/
no such column: cnc_hardwareflowcontrolmachine.serialmachine_ptr_id
Request Method: GET
Request URL: http://127.0.0.1:8000/admin/cnc/hardwareflowcontrolmachine/
Django Version: 1.4
Exception Type: DatabaseError
Exception Value:
no such column: cnc_hardwareflowcontrolmachine.serialmachine_ptr_id
Exception Location: C:\Python27\lib\site-packages\django\db\backends\sqlite3\base.py in execute, line 337
Python Executable: C:\Python27\python.exe
Python Version: 2.7.2SoftwareFlowControlMachine:
DatabaseError at /admin/cnc/softwareflowcontrolmachine/
no such column: cnc_softwareflowcontrolmachine.serialmachine_ptr_id
Request Method: GET
Request URL: http://127.0.0.1:8000/admin/cnc/softwareflowcontrolmachine/
Django Version: 1.4
Exception Type: DatabaseError
Exception Value:
no such column: cnc_softwareflowcontrolmachine.serialmachine_ptr_id
Exception Location: C:\Python27\lib\site-packages\django\db\backends\sqlite3\base.py in execute, line 337
Python Executable: C:\Python27\python.exe
Python Version: 2.7.2如果我需要提供更多信息,请告诉我。我真的不确定我错过了什么
发布于 2012-04-19 14:34:28
我把它修好了。然而,我仍然不清楚为什么会发生这种情况。我犯的一个错误是
machineSettings = SerialMachine.objects.get(machineName=machine).select_subclasses()我需要这个
machineSettings = SerialMachine.objects.get_subclass(machineName=machine)我还删除了我的数据库,并重新创建了它。
希望这对其他人也有帮助
https://stackoverflow.com/questions/10201890
复制相似问题