在新鲜的sqlite3中导入csv以与新项目django 2.1一起使用

时间:2018-10-22 04:09:44

标签: python django python-3.x django-models sqlite

我真的不知道该如何正确地表达这个问题,但希望我可以在这里弄清楚。

我的最初目标是在新的sqlite3数据库中导入CSV文件,并让我的应用程序model.py与之一起使用

这是表格的样子(这是从csv文件导入的) enter image description here

我重命名了Table以使其适合应用程序的命名格式

appname:定位

这是locate / model.py文件的图片: enter image description here

我将每个变量命名为与导入的CSV文件中的表相同

此后,我当然将应用程序放置在设置中并进行了迁移,并遇到以下错误:

django.db.utils.OperationalError: there is already another table or index with this name: locate_professor

有人知道我将如何正确配置它!! 谢谢!

1 个答案:

答案 0 :(得分:1)

在导入csv文件之前,您可能需要迁移模型。 或者您可以将模型的托管设置为false。 不建议使用第二种方法。