Python circular importing?

后端 未结 7 1021
不知归路
不知归路 2020-11-22 05:46

So i\'m getting this error

Traceback (most recent call last):
  File \"/Users/alex/dev/runswift/utils/sim2014/simulator.py\", line 3, in 
    f         


        
7条回答
  •  长情又很酷
    2020-11-22 06:24

    For those of you who, like me, come to this issue from Django, you should know that the docs provide a solution: https://docs.djangoproject.com/en/1.10/ref/models/fields/#foreignkey

    "...To refer to models defined in another application, you can explicitly specify a model with the full application label. For example, if the Manufacturer model above is defined in another application called production, you’d need to use:

    class Car(models.Model):
        manufacturer = models.ForeignKey(
            'production.Manufacturer',
            on_delete=models.CASCADE,
    )
    

    This sort of reference can be useful when resolving circular import dependencies between two applications...."

提交回复
热议问题