How to run an external python script in my Django view
2,082 views
Skip to first unread message
raman....@gmail.com
unread,
Jan 15, 2016, 9:56:07 AM1/15/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
Hi,
I have a script which is running fine and giving output in the form of list of lists. I want to use that data in my Django view. I am not getting, how to run a script in django view.
I created a folder utils inside which, I have put the script. Also, I have created __init__.py in the utils folder. Then, I am importing it in my views as "from utils.scriptname import classname". I'm struggling in that from long and appreciate help.
Thanks
Larry Martell
unread,
Jan 15, 2016, 10:02:51 AM1/15/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django...@googlegroups.com
What happens when you invoke the script?
raman....@gmail.com
unread,
Jan 16, 2016, 2:28:52 AM1/16/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
Thanks Larry for the reply. Nothing is happening after invoking the script(I think, I am doing something wrong in using the python script in Django views). I have tried running the script separately which is working fine and giving the output.
raman....@gmail.com
unread,
Jan 16, 2016, 2:30:58 AM1/16/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
Thanks Larry for the reply. Nothing is happening after invoking the script(I think, I am doing something wrong in using the python script in Django views). I have tried running the script separately which is working fine and giving the output.
On Friday, January 15, 2016 at 8:32:51 PM UTC+5:30, Larry....@gmail.com wrote:
Message has been deleted
Luis Zárate
unread,
Jan 16, 2016, 9:00:28 AM1/16/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django...@googlegroups.com
How you call your script in the view? You said that is import as from utils.scriptname import classname but what method do you call in the view.
Remember, all code in script file that are not in a function o class will execute at import time.
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django...@googlegroups.com
On Sat, Jan 16, 2016 at 2:28 AM, <raman....@gmail.com> wrote:
> Thanks Larry for the reply. Nothing is happening after invoking the script(I
> think, I am doing something wrong in using the python script in Django
> views). I have tried running the script separately which is working fine and
> giving the output.
I would set a breakpoint with pdb in the view and then run the django
devel server and when you hit the bp step into the invocation of your
script and see what happens.