2013-05-15 41 views
1

大家好人都可以幫助我這個我有導入錯誤,當我做一個導入我認爲它的所有衝突。所有罰款,直到我導入B,因爲我真的需要一個ForeignKey從A.交叉導入時導入錯誤django/python

一個/ models.py

from b.models import B #there is the problem 
Class A(): 
    .... 
    b = models.ForeignKey(B) # I really have to do this 

b/models.py

from c.models import C 

Class B(): 
    .... 
    c = models.ForeignKey(C) 

C/models.py

b
from a.models import A 
Class C(): 
    a = models.ForeignKey(A) 

回答

5

你可以做到這一點(不導入B型,只要輸入格式 「app_name.model_name」 的字符串)

A/models.py

Class A(): 
    .... 
    b = models.ForeignKey("b.B") 

ForeignKey docs

+0

這個工程很好,謝謝一百萬 – user1940979