Jani is right, I didn't take a close look at that HTML. Using this (without any Javascript), you're not submitting a form with method="post" so you won't actually have any of that request.POST data available that you're looking for.
On Fri, May 4, 2012 at 3:58 AM, Jani Tiainen <rede...@gmail.com> wrote: > > 4.5.2012 1:22, psychok7 kirjoitti: > > hi i have done a succefull query and i converted the results into links >> so i can make a post by clicking on the links to make a reservation. >> > > No, you haven't. When you click you'll still send very much standard GET > request to server. You can and should verify that by using some debugging > console. > > > my problem is, theres a variable timeout that i want to specify >> manually, but i get a "Key 'timeout' not found in <QueryDict: {}>" >> >> i know i am supposed to pass that variable but i just dont know how. >> > > my code is : >> >> def reserve (request,user_id,park_id): >> #only works if the user exists in database >> u = get_object_or_404(User, pk=user_id) >> n = get_object_or_404(**Notification, pk=park_id) >> p = get_object_or_404(Park, pk=1) >> r = Reservation(user=u ,notification=n, park=p, >> timeout=int(request.POST['**timeout']),active=True,parked=** >> False,reservation_date=**datetime.now()) >> r.save() >> return HttpResponse('Spot reserved') >> >> html: >> >> {% if parks %} <p>You searched for: <strong>{{ query }}</strong></p> >> <p>Found {{ parks|length }} park{{ parks|pluralize }}.</p> <ul> {% for >> park in parks %} <input type="text" name="timeout" value="60" >> id="timeout"> <li><a href="/accounts/{{ user.id }}/reserve/{{ park.id >> }}">{{ park.park_address }}</a></li> {% endfor %} </ul> {% endif %} >> >> can someone help me? >> > > If above is your true HTML and nothing removed you're just creating list > of standard links. > > If you want to pass additional parameters there is few ways to achieve it: > > a) You can modify your sent url by javascript and add timeout manually to > get query parameters. > > b) You transform your links to selectable list/dropdown and create real > HTML form to send post with real submit button. > > c) Hybrid of a and b. I won't go into details since it would be just a > mess. > > -- > Jani Tiainen > > - Well planned is half done and a half done has been sufficient before... > > > -- > 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 <django-users%2bunsubscr...@googlegroups.com>. > For more options, visit this group at http://groups.google.com/** > group/django-users?hl=en<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. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.