Interaction of Python Code with Django.

76 views
Skip to first unread message

SUBHABRATA BANERJEE

unread,
May 12, 2015, 10:59:47 AM5/12/15
to django...@googlegroups.com
Dear Group,

I want to integrate an interactive Python code, (it takes user input, processes input and gives output), with Django.
I am new to Django, using Python2.7.9 on Windows 7 Professional.

I am researching on it, but as it is a room for Django experts, I am trying to post this
question, if anyone may kindly suggest how may I proceed? An example or web based tutorial would be great.

Regards,
Subhabrata Banerjee.

palansh agarwal

unread,
May 12, 2015, 11:06:32 AM5/12/15
to django...@googlegroups.com
Hi,
https://github.com/py-geek/Startup-job-search
look at the code in this repo an try to understand. It's a simple job search portal developed by me.  A simple way is to use a simple HTML form and map it's action attribute to a url. map that url to a method in your urls.py file. write this method in your viws.py file. Put all your logic in this method and return the result appropriately.
Regards,

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/10699b8a-3e40-42e6-a131-85d78e55a5ec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
PALANSH AGARWAL
Y13UC185
Computer Science Engineering
2nd Year
The LNM Institute of Information Technology, Jaipur

Gergely Polonkai

unread,
May 12, 2015, 3:38:49 PM5/12/15
to django...@googlegroups.com

The tricky part here is providing the input for the interactive tool. For shell scripts there is a software called expect, you may want to look for Python alternatives. Of course, if this interactive tool reads sequential input from stdin and sends output to stdout, there are much easier solutions, as in this case you can simply use a subprocess (which in itself can be tricky, if the tool is not well tested for malicious input).

SUBHABRATA BANERJEE

unread,
May 13, 2015, 5:40:27 AM5/13/15
to django...@googlegroups.com
Thanks Palansh. I have few questions here.
a) I saw you have created a job search engine. I found its html source. Nice.
b) I found your Django codes.
My questions are,
i) Where you are calling html source in your django code.
ii) Is there any tutorial to learn this? I wanted to know it.

Thanks Gergely, I am trying to check pexpect.

Regards,
Subhabrata Banerjee.

palansh agarwal

unread,
May 13, 2015, 5:43:54 AM5/13/15
to django...@googlegroups.com
Hello,
I suggest you go through django official docs first. The methods in views.py returns response on a HTML templates. Look for them and try to understand the workflow.


For more options, visit https://groups.google.com/d/optout.

SUBHABRATA BANERJEE

unread,
May 13, 2015, 6:13:35 AM5/13/15
to django...@googlegroups.com
Hi Palansh,

Thank you for your prompt answer, is it,
return HttpResponse(template.render(context))

https://docs.djangoproject.com/en/1.8/intro/tutorial03/
under
Write views that actually do something
and you have worked out views.py

Regards,
Subhabrata Banerjee.

palansh agarwal

unread,
May 13, 2015, 6:53:16 AM5/13/15
to django...@googlegroups.com
Hi,
Yes you got it right.


For more options, visit https://groups.google.com/d/optout.

sarfaraz ahmed

unread,
May 13, 2015, 6:58:28 AM5/13/15
to django...@googlegroups.com
 werkzeug is another debug tool which let you write and test code via browser itself. 

Regards,
Sarfaraz Ahmed


For more options, visit https://groups.google.com/d/optout.



--
Thanks with regards,
Sarfaraz Ahmed


SUBHABRATA BANERJEE

unread,
May 13, 2015, 7:25:20 AM5/13/15
to django...@googlegroups.com
Thanks, but that is more or less on Flask. In Django I could do  Rest with restonframeworks. Now I have to integrate it with my existing code in Python.
Palansh has developed almost similar but I am looking for an interactive rest based django api for my interactive python code.
Seems bit stuck. Web search is not giving much help. If any one may kindly suggest.

Regards,
Subhabrata Banerjee.

SUBHABRATA BANERJEE

unread,
May 13, 2015, 8:23:56 AM5/13/15
to django...@googlegroups.com
Hi Palansh,

May I ask you two or three quick questions.
a) Am I understanding fine?
b) I wrote a Python Script, and wanted to port it with Django restonframework. I could do upto Django restonframework. How may I go next?
If you may kindly suggest.

Regards,
Subhabrata Banerjee.


On Tuesday, May 12, 2015 at 8:36:32 PM UTC+5:30, palansh agarwal wrote:
Reply all
Reply to author
Forward
0 new messages