2

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
  • 1
    you don't actually need any database when using django. you can work without a database (and some things won't work). Commented Aug 13, 2012 at 12:50

1 Answer 1

4

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))
Sign up to request clarification or add additional context in comments.

2 Comments

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.