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 new
> > keyword for rosebud to crawl!">*
>
> Your immediate problem here is that your <input> element has an id, but no
> name attribute. That is why you are getting None when you try to retrieve
> it from the POST dictionary -- the browser never sent it to the server.
>
> I'm certain that you have additional issues with your view function, but
> this 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 method
> > keyword_subscribe in views.py
>
> > The 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 user
> > entered in the textfield and store it in a variable called new_keyword
>
> > However, i've been getting NONE which means there's something wrong
> > somewhere and i do hope someone can help me.
>
> > In addition, i would like to get the username which is stored in the
> > UserProfile table in my database to be passed as a parameter to the next
> > function too.
>
> > How then do i implement the queryset needed?
>
> > This should be clearer.
>
> > Thank you.
>
> > Best Regards,
>
> > Stanwin Siow
>
> > On Feb 26, 2012, at 6:25 PM, Daniel Roseman wrote:
>
> > Your question is not at all clear. You can use whatever you like in your
> > view. 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 visit
> >https://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 to
> > django-users+unsubscribe@googlegroups.com <javascript:_e({}, 'cvml',
> > 'django-users+unsubscribe@googlegroups.com');>.
> > For more options, visit this group at
> >http://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 to
> > django-users+unsubscribe@googlegroups.com <javascript:_e({}, 'cvml',
> > 'django-users%2Bunsubscribe@googlegroups.com');>.
> > For more options, visit this group at
> >http://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