You should rewite the method: def commodity(request, commodity_id): p = get_object_or_404(Commodity, pk=commodity_id) return render_to_response('fsafety/commodity_detail.html', {'commodity': p})
to def commodity(request): commodity_id = request.POST['commodity'] # this variable comes from the form (select value) p = get_object_or_404(Commodity, pk=commodity_id) return render_to_response('fsafety/commodity_detail.html', {'commodity': p}) Best regards, Wai Yi May schreef: > Hello All, > > Thank you for the suggestions. I am getting closer to figuring it > out. Now my error is this: > > commodity() takes exactly 2 arguments (1 given) > > My URL is: > (r'^commodity/$', 'commodity'), > > The Form statement: > <form action="/fsafety/commodity/" method="POST"> > > Thank you! > > May > > On Jan 13, 10:56 am, Wai Yi Leung <tweak...@gmail.com> wrote: > >> Hi May, >> >> Try to debug in shell, this will give you more information. >> Lets print the 'p' value after having it set with get_object_or_404 ... >> >> And I think you are a bit messing with which method to call. You are >> generating the page with the form that contains errors. So lets check >> your index() method also. >> This method doesn't assign commodity to any variable in the response. >> >> Good luck in bughunting. >> >> Wai Yi >> >> May schreef: >> >> >>> Hello, >>> >>> I tried the URL and still received this error: >>> Page not found (404) >>> Request Method: POST >>> Request URL: http://127.0.0.1:8000/fsafety//commodity_detail/ >>> >>> I think now that the ID is not getting passed to this line: >>> <form method="POST" action="/fsafety/{{commodity.id}}/ >>> commodity_detail/"> >>> >>> Thank you for any help you can give. >>> >>> May >>> >>> On Jan 13, 10:25 am, Santiago <santiago.j.zar...@gmail.com> wrote: >>> >>>> replace in your url.py: >>>> >>>> (r'^(?P<commodity_id>\d+)$/commodity_detail/', 'commodity'), >>>> >>>> by >>>> >>>> (r'^(?P<commodity_id>\d+)/commodity_detail/$', 'commodity'), >>>> >>>> this _should_ work >>>> >>>> 2009/1/14 May <adles...@gmail.com>: >>>> >>>>> My error is not being able to get the ID passed to the next >>>>> template. >>>>> >>>>> The code: >>>>> >>>>> http://dpaste.com/108580/ >>>>> >>>>> Thank you, >>>>> >>>>> May >>>>> >> > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---