I've got it working thanks to your inputs.
Really appreciate it.
Best Regards,
Stanwin Siow
On Feb 27, 2012, at 4:36 PM, doniyor wrote:
yes, as Ian said, you need name attr in your input so that you can
navigate to the real string input the user gives..
On 27 Feb., 08:38, Ian Clelland <clell...@gmail.com> wrote:On Sunday, February 26, 2012, Stanwin Siow wrote:Ok disregard my previous question.Here's the latest one.I have the following form in my HTML:* <form method="POST" id="keywordForm" action="/keyword_subscribe/">** <label>Keyword: </label>** <input id="myTextField" type="text" size="50" value="Enter a newkeyword for rosebud to crawl!">*Your immediate problem here is that your <input> element has an id, but noname attribute. That is why you are getting None when you try to retrieveit from the POST dictionary -- the browser never sent it to the server.I'm certain that you have additional issues with your view function, butthis is the reason for the error that you are seeing right now.Ian* </br>** <input type="submit" value="Submit" />** </form>*when the user presses the submit button, it will go to the methodkeyword_subscribe in views.pyThe method is as shown:*def keyword_subscribe(request):** if request.POST:** username = UserProfile.objects.all()** #userid = username.objects.all()** subscription_days = "7"** new_keyword = request.POST.get('myTextField')** print new_keyword** new_keyword_subscribed =subscribe_keyword(username,subscription_days,new_keyword) ** ** response = simplejson.dumps({'new_keyword':new_keyword_subscribed}) ** print new_keyword_subscribed ** else:** # html = form.errors.as_ul()** response = simplejson.dumps({'success':'False'})** return HttpResponseRedirect("/accounts/login/")** #if request.is_ajax():** # return HttpResponse(response, mimetype='application/json')** #else:** # return HttpResponseRedirect("/")*Once in this method, i'm supposed to extract the word which the userentered in the textfield and store it in a variable called new_keywordHowever, i've been getting NONE which means there's something wrongsomewhere and i do hope someone can help me.In addition, i would like to get the username which is stored in theUserProfile table in my database to be passed as a parameter to the nextfunction too.How then do i implement the queryset needed?This should be clearer.Thank you.Best Regards,Stanwin SiowOn Feb 26, 2012, at 6:25 PM, Daniel Roseman wrote:Your question is not at all clear. You can use whatever you like in yourview. What problem are you having?--DR.--You received this message because you are subscribed to the Google Groups"Django users" group.To view this discussion on the web visithttps://groups.google.com/d/msg/django-users/-/1N2Cz2nv9wQJ.To post to this group, send email to django-users@googlegroups.com<javascript:_e({}, 'cvml', 'django-users@googlegroups.com');>.To unsubscribe from this group, send email todjango-users+unsubscribe@googlegroups.com <javascript:_e({}, 'cvml','django-users+unsubscribe@googlegroups.com');>.For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.--You received this message because you are subscribed to the Google Groups"Django users" group.To post to this group, send email to django-users@googlegroups.com<javascript:_e({}, 'cvml', 'django-users@googlegroups.com');>.To unsubscribe from this group, send email todjango-users+unsubscribe@googlegroups.com <javascript:_e({}, 'cvml','django-users%2Bunsubscribe@googlegroups.com');>.For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.--Regards,Ian Clelland<clell...@gmail.com>
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment