On Sun, 2009-01-18 at 12:11 +0800, shreyas k wrote:
> 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.

That's probably a bad idea, in the sense that it's against the
recommendations of the HTTP specification. Both editing and deleting are
actions that significantly change the state of the system (they aren't
"safe" operations). So using GET for them is not recommended.

> 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:      

So if you expect the code to pass through this line successfully and it
doesn't, the obvious thing to investigate is what does request.GET
contain? You still haven't revealed what the form looks like (or a
cut-down version of the form, at least, that reveals the problem without
requiring us to wade through 350 lines of HTML :-) ). Is delete_id a
field in the form? Will it always be submitted (for example, checkboxes
that aren't checked are not submitted with a form)? What does
request.GET contain?

I'll wager that looking at the contents of request.GET will give you
(not necessarily us) enough of a clue to work out what's going wrong.
You'll see that it's either nothing like what you expect, or it's only
missing that particular form parameter and you'll be able to work out
why it's missing.

Regards,
Malcolm

> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to