在我的Django应用程序中,我有模型:
class Voivodeship(models.Model):
name = models.CharField(max_length=20, primary_key=True)
我还有从原始数据构建数据库的脚本:
import app.models as models
...
voivodeships[name] = models.Voivodeship(name=name)
voivodeships[name].save()
但是当我尝试使用exec(python manage.py shell
)在exec(open('filler.py').read())
中解释它时,它会返回错误:
'Voivodeship' object has no attribute '_state'
而且我不知道发生了什么。你能建议我解决吗?