python - 使用 Django 在函数中调用函数会导致 NameError
问题描述
为了保持我的项目干净,我的CalculationLogic类有模块。我在我的views.py文件中调用这个类,比如:
def method_in_views_file(request):
cl = CalculationLogic()
return cl.method_in_calculation_logic()
在我的CalculationLogic中:
def other_function(self,x):
# some logic here #
return result
def method_in_calculation_logic(self,args):
# some logic here #
x = ['x','y','z']
data = other_function(x)
return render(request,'file.html',{'data':data})
不幸的是,在我的浏览器中调用此视图后,我得到 NameError未定义其他函数。哪一部分可能是错的?
解决方案
推荐阅读
- pine-script - 运行简单的 Pinscript 策略的问题
- javascript - 为什么跳过子进程来运行我的 Python 脚本?
- makefile - 如何在 Ubuntu-Linux 上设置 meson 和 ninja 以使用 MakeFile 生成预期的 .a 文件?
- java - Java将JSON列表中的所有元素合并为一个元素
- adb - 如何使用本地设备为远程桌面设置 ADB?
- python-3.x - python安装命令提示符
- r - 如果值存在于 R 中的其他列中,则用于创建 T/F 列的 dplyr 解决方案
- react-native - 打开类似 Pinterest 的操作弹出菜单(React-Native)
- javascript - 如何每两秒显示给定的随机数组元素,直到它停止?
- java - android studio 在屏幕解锁时进行套接字连接?(java)