Есть такой код:
class Services(models.Model):
typeClassify = models.CharField(max_length=100,null=True)
childTypeClassify = models.CharField(max_length=100, null=True)
name = models.CharField(max_length=100)
id = models.AutoField(primary_key=True)
contentExt = models.CharField(max_length=100,null=True)
content = models.CharField(max_length=100,null=True)
class Extendedimg(models.Model):
img1 = models.CharField(max_length=100,null=True)
img2 = models.CharField(max_length=100,null=True)
img3 = models.CharField(max_length=100,null=True)
img4 = models.CharField(max_length=100,null=True)
img5 = models.CharField(max_length=100,null=True)
img6 = models.CharField(max_length=100,null=True)
img7 = models.CharField(max_length=100,null=True)
img8 = models.CharField(max_length=100,null=True)
img9 = models.CharField(max_length=100,null=True)
img10 = models.CharField(max_length=100,null=True)
imgBg = models.CharField(max_length=100,null=True)
serviceId = models.OneToOneField(Services,on_delete=models.CASCADE, primary_key=True)
def recordSerivces(service):
serviceInst = Services(
name=service['name'],
id=service['id'],
childTypeClassify=service['childTypeClassify'],
typeClassify=service['typeClassify'],
contentExt=service['contentExt'],
content=service['content'],
)
serviceInst.save()
return serviceInst
def recordImages(serviceField):
id = serviceField.id
urls = {}
for num in range(1,11):
urls.update({f"img{num}": f"https://domain-name/assets-static/services/list/{id}/img{num}.png"})
urls.update({"imgBg": f"https://domain-name/assets-static/services/list/{id}/imgbg.png"})
imagesInst = Extendedimg(serviceId=serviceField,**urls)
imagesInst.save()
return imagesInst
for service in servicesData:
serviceInst = recordSerivces(service)
imagesInst = recordImages(serviceInst)
То есть есть какой-то json файлик, который я прогоняю через модели.
Но почему-то imagesInst.save() выдает ошибку models aren't loaded yet
С чем это может быть связано?