2012-04-18 2 views
1

차고 가게의 취미 프로젝트 작업 중입니다. 나는 내가 필요로하는 것을 장고 - 모델 - 유틸리티 (django-model-utils)에게 보냈다.Django 다중 테이블 상속, Django-model-utils 오류

내가 SerialMachine의 상위 클래스가 (I은 직렬 시스템은 두 개의 흐름 제어 방법이 시리얼 CNC 머신을 가지고)

(어드레스, 전송 속도, 일반적인 RS-232의 정의를 정의) 다음 I 상속 HardwareFlowControlMachine 모델을 SerialMachine (CTS/DTR/등 정의)

그래서 기계 이름을 양식 (예 : 기계 001)에 넣으면 기계 설정을 가져 오는 기능이 있습니다.

def getMachineSettings(machine): 

    from src.apps.cnc.models import SerialMachine 

    machineSettings = SerialMachine.objects.get(machineName=machine).select_subclasses() 

    return machineSettings 

나는이 예외를 얻을 :

난 단지 SoftwareFlowControlMachine (하드웨어 없음) 나는 어쩌면 HardwareFlowControlMachine가 어떤 이유에서 적어도 하나 개의 객체를 필요하다고 생각

하나의 기계를 가지고 테스트를 위해 지금

DatabaseError: no such column: cnc_hardwareflowcontrolmachine.serialmachine_ptr_id 

.

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 

이 날 경우 알려

HardwareFlowControlMachine : 내가 갈 때 그래서/관리자는/나는이 예외가 SoftwareFlowControlMachine 또는 HardwareFlowControlMachine 중 하나에 시스템을 추가하려고 나는 더 많은 정보를 제공해야한다. 나는 내가 무엇을 놓쳤는 지 정말로 모른다.

답변

0

나는 그것을 얻었다. 나는 아직도 그것이 왜 일어 났는지에 관해 명확하지 않다. 내가 만든 실수는 내가 아니라 내 데이터베이스를 삭제하고 다시 만들어이

machineSettings = SerialMachine.objects.get_subclass(machineName=machine) 

을 필요로하는 대신

machineSettings = SerialMachine.objects.get(machineName=machine).select_subclasses() 

이다.

희망은 다른 사용자에게도 유용합니다.