尝试在Django中运行python脚本

2024-04-19 01:31:23 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试运行python脚本,该脚本使用django中定义的一些模型,django随后位于docker容器中。我使用以下命令:

sudo docker-compose -f production.yml run django python manage.py shell < send.py

但我一直有个错误:

IndentationError: unexpected indent
  File "<console>", line 1
    stats = grp_px.calc_stats(dropna=False)
    ^
IndentationError: unexpected indent
  File "<console>", line 1
    st = stats.render_perf(key=key)
    ^
IndentationError: unexpected indent
  File "<console>", line 1
    perf_list.append([key, st.render()])
    ^
IndentationError: unexpected indent
  File "<console>", line 1
    send_mail(html_message=render_to_string('fund_vs_peers.html', {'perf_list': perf_list}),
    ^
IndentationError: unexpected indent
  File "<console>", line 1
    message='',
    ^

基本上,我的每一行代码都有一个缩进错误。有什么想法吗?你知道吗


Tags: djangokeydockerpy脚本statslinerender