[英]how to import python code into views.py file in django
I am new to django and I am trying to link a response from a form submission to a couple python methods I wrote in a different file which will use the user input as parameters. 我是django的新手,我正在尝试将表单提交的响应链接到我在不同文件中编写的几个python方法,这些方法将使用用户输入作为参数。 I am wondering how I can import those methods and print their results.
我想知道如何导入这些方法并打印结果。
My python file is named Crunch.py
and is located in the same directory as views.py
I have tried: from Crunch import *
but it isn't working. 我的python文件名为
Crunch.py
,与views.py
位于同一目录中我尝试过: from Crunch import *
但它无效。 I would like to know if I need to move the file elsewhere or what I need to write to import all the methods from Crunch. 我想知道我是否需要将文件移动到别处或我需要写什么来从Crunch导入所有方法。
请尝试以下方法
from <app name>.Crunch import *
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.