简体   繁体   English

如何在Django中创建python脚本在数据库中添加行

[英]How to create python script to add row inside database in Django

I tried to run this script but definitely something missing here... mysite this is the app, School is the class 我试图运行此脚本,但肯定缺少某些内容... mysite这是应用程序, School是该类

from mysite.models import School
school1 = School(name='Oxford school', address='Shole St.33', email='ox-scholl@gmail.com', phone_number='3445348910')
school1.save()

And get this error: raise AppRegistryNotReady("Apps aren't loaded yet.") django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. 并得到以下错误: 引发AppRegistryNotReady(“尚未加载应用程序。”)django.core.exceptions.AppRegistryNotReady:尚未加载应用程序。

正如Ganesh Negi提到的那样: Django:AppRegistryNotReady() ,但是您也可以使用固定装置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM