I have a python code that takes few inputs from user and gives the output. It doesn't require any database. Now I want to build a web interface using django. I want to know how the python code can be integrated to django for the web interface without using any database.
1 Answer
You don't need to use the database. Just write your Python code into the view and put the output into the dictionary passed to the render function.
views.py:
def my_view(request):
# Do stuff and set value
return render_to_response('my_page.html',
{'value': value},
context_instance=RequestContext(request))
2 Comments
Pradeep Tandon
Suppose my page is a login page and i need to give a username and a password to login. Now what will my dictionary be ?? I have decided to give access to only 2 accounts. So should my key value be fixed with the two accounts in the dictionary..
deadly
@PradeepTandon You'd get the username and password that the user entered from the request.POST data. The dictionary is used for passing data to the template for rendering. Does that answer your question?