Hi Malcolm, sorry the indent was lost when i copy pasted the code , the try statement is actually properly indented .And the if if request.method == 'GET': is followed by if request.method == 'POST': > i have also trimmed the code .I use post for update and add new .Editing and deleteing,listing is done using GET request.
if request.method == 'GET': if 'edit_id' in request.GET: try: tst = TEST_QST.objects.get(pk=request.GET['edit_id']) SaveQstForm = forms.form_for_instance(tst) SaveQstForm related code here form= SaveQstForm() except Exception, e: import logging logging.error('%s while editing' % (e)) if 'delete_id' in request.GET: try: delete related code here except Exception, e: q_list = TEST_QST.objects.all() form= QstForm() message = 'Error Deleting question !!!!!!!!!' else: import logging code -->to be done at else codition return render_to_response('editor1.html', { 'form': form, 'submit_action': submit_action }) if request.method == 'POST': Regards Shreyas On Sun, Jan 18, 2009 at 10:25 AM, Malcolm Tredinnick < malc...@pointy-stick.com> wrote: > > On Sun, 2009-01-18 at 10:21 +0800, shreyas k wrote: > > Hi , > > > > I have pasted the code here , when i try to edit it always enters the > > else condition. delete works fine > > Please assist. > > There's a lot of code here and much of it isn't indented correctly (for > example, there's a "try:" statement that isn't followed by an indented > block), so it's hard to be sure what might be the problem. Try trimming > away as much as possible to reduce things to the smallest possible > example. > > One obvious guess here, though, is that you are only checking for the > GET method. If you're submitting a form that is going to delete > something, it would hopefully be done using the POST method. So > delete_id won't be in request.GET. It will be in request.POST and should > be handled by the branch of your code that is handling request.method > being equal to "POST". This is only a guess, though, since I don't know > how you are submitting data from the form to this view or what data the > form contains. > > Regards, > Malcolm > > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---