I am working on a hobby project for my garage shop. I was directed to django-model-utils for what I need. (I have serial CNC machines, serial machines have two flow control methods)
I have a parent class of SerialMachine (defines address, baud rate, generic RS-232 definition)
Then I have HardwareFlowControlMachine model which inherits from SerialMachine (defines CTS/DTR/etc)
So when I put machine name into a form (say machine 001) I have a function that get's machine settings.
def getMachineSettings(machine):
from src.apps.cnc.models import SerialMachine
machineSettings = SerialMachine.objects.get(machineName=machine).select_subclasses()
return machineSettings
I get this exception:
DatabaseError: no such column: cnc_hardwareflowcontrolmachine.serialmachine_ptr_id
Now for testing I only have one machine in SoftwareFlowControlMachine (none in Hardware)
I thought maybe HardwareFlowControlMachine needed at least one object for whatever reason. So when I go to /admin/ and try to add a machine to either SoftwareFlowControlMachine or HardwareFlowControlMachine I get this exception:
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.2
SoftwareFlowControlMachine:
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
Let me know if I need to provide more info. I am really not sure what I am missing
I got it working. I'm still unclear on why it happened though. A mistake I made is instead of
machineSettings = SerialMachine.objects.get(machineName=machine).select_subclasses()
I needed this
machineSettings = SerialMachine.objects.get_subclass(machineName=machine)
I also just deleted my database and remade it.
Hope this helps others too