Hi,
I am new to Django and Python, and web programming in general.
I have a very simple form and the dictionary request.POST does not
store the information correctly. I may be doing something wrong, so
please help me.
urls.py:
urlpatterns += patterns( (r'^photo/info/$', 'views.info'), )
form.html: (relavant contents )
<form action="/photo/info/"
method="post" enctype="text/plain">
<p>Tags: <br />
<input type="text" name="tag_str"
value="some_default_value" size="60" />
</p>
<p>Title:<br />
<input type="text" name="title_str"
value="some_default_value" size="60" />
<br>
</p>
<p>
Caption:<br />
<textarea name="caption_str" rows="10" cols="60">some_text</textarea>
</p>
<br><br>
<input type="submit" value="Save" />
<input type="reset" value="Reset" />
</form>
views.py:
def info(request):
if request.method == 'POST':
print request.POST['tag_str']
print request.POST['title_str']
return HttpResponse('testing')
After the form is rendered, I enter the following:
For Tags : tag1, tag2
For Title: This is the title
For Caption: Some random paragraph
Now here is the problem: print request.POST['tag_str'] in function
views.info prints the following:
tag1, tag2 title_str=This is the title caption_str=Some random
paragraph
and print request.POST['title_str'] returns error because key
'title_str' is not found.
What am I doing wrong? Why are the keys and their respective values in
tag_str?
Thanks.
Regards,
Bala.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-developers
-~----------~----~----~----~------~----~------~--~---