0

I have a input box that, when submitted gives a python method a POST (I'm using django). I'd like to have the search term that the user entered so that I can call methods upon it, preferably in string form.

How do I do that?

1
  • Do you want to get the text client side, or server side? Commented Sep 17, 2011 at 14:46

1 Answer 1

2

In your view, you can get POST parameters like this:

def myview(request):
    p = request.POST['parameter']
    # do something with p
    # return http response
Sign up to request clarification or add additional context in comments.

3 Comments

hey- that doesn't work - it's throwing an error key 'parameter' error not found in QueryDict
Sigh. 'parameter' was an example. Use the name of your input.
It might be good to use request.POST.get("parameter") instead of request.POST["parameter"]. The former does not throw an exception if parameter is not given in the form, the latter does. Since it is related to the user input, invalid inputs should not raise HTTP 500 but handled properly by coder.

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.