Cas*_*sey 5 python django heroku
我有一个Django应用程序并在Heroku上运行.我想运行一个名为import.py的简单脚本,它将CSV文件导入到我的模型中.它在我的本地计算机上运行良好.当我尝试使用此命令在Heroku上运行脚本时:
heroku run python manage.py < import.py
Run Code Online (Sandbox Code Playgroud)
它只是将脚本读回给我,但不执行任何内容.我究竟做错了什么?
编辑:
这是我运行时获得的结果的开始:heroku运行python manage.py <import.py
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import csv
>>> from bah_api.models import withDependents, withOutDependents, ZipMHA
>>>
>>> # Populate CSV file into model
>>> def LoadCSV(file_location, my_model, delim):
... f = open(file_location)
File "<console>", line 2
f = open(file_location)
^
IndentationError: expected an indented block
>>> csv_f = csv.reader(f, delimiter=delim)
Traceback (most recent call last):
File "<console>", line 1, in <module>
NameError: name 'f' is not defined
>>> for row in csv_f:
...
Display all 182 possibilities? (y or n)
Run Code Online (Sandbox Code Playgroud)