我所要做的是重写我的一个模型的save方法Shastra
class Shastra(models.Model):
something = models.IntegerField()
def save(self, *args, **kwargs):
post_content(app='shastra', content=self)
super(Shastra, self).save(*args, **kwargs)
# The function being called in the override function
def post_content(*args, **kwargs):
FbApiContent(content = kwargs['content']).save()
# The model being used by the override function
from shastra.models import Shastra
class FbApiContent(models.Model):
content = models.ForeignKey(Shastra)
我不知道发生了什么事:|,有什么见解我将不胜感激
看起来你有一个循环导入。在
shastra\models.py
正在执行from fb_api.api import *
fb_api\api.py
正在执行from fb_api.models import FbApiUser
fb_api\models.py
正在执行from shastra.models import Shastra
即使您只是从一个模块导入一个类,整个模块也会被执行来填充它的命名空间。在
循环导入。解析它,或者使用string作为FK参数(
models.ForeignKey('app.Shastra')
)。在相关问题 更多 >
编程相关推荐