how to import python code into views.py file in django
Asked Answered
A

2

9

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. 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. 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.

Athiste answered 28/8, 2012 at 23:54 Comment(1)
do you get errors? what is not working? you should post some code...Anorak
A
23

Try the following

from <app name>.Crunch import *
Absentee answered 29/8, 2012 at 0:14 Comment(0)
E
1

This will also do

from .Crunch import *
Exclaim answered 11/2, 2023 at 18:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.