Hi,

I would use the forms library, even if the form has only one input element.
I would use django.http.HttpResponseRedirect() to the list view, after
successful
deletion.


Aldo schrieb:
> Hi folks,
>
> MY URL is x.y.z/list
> It shows a list of objects. They have link buttons to delete/update
> for each object.
>
> When I click delete for an object I go to a URL via POST with the
> object id in the url
> This brings me to a "Are you sure you want to delete this object
> page".
> MY URL is x.y.z/list/3
>
> I click submit and it deletes the object and brings me back to the URL
> page at the top /list.
>
> My problem is my delete function :
>
> def delete(request,  id):
>     if request.method == 'POST':
>         if verify(id):
>                 MyObject.objects.get(pk=id).delete()
>                 #Go back to the list
>                 return render_to_response('html/list.html',
> {'objects':MyObjects.objects.all())
>         if request.method == 'GET':
>             if verify(id):
>                return render_to_response('html/delete.html',
> {'token':token, 'id':id})
>         return render_to_response('html/404.html')
>
> Is there a neater way of doing this - rather than finding the request
> type and behaving differently depending.
>
> I am doing a similar thing for my update and it just seems off.
>
> Please help.
>
>
>
>
>
>
>
> >
>   


-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de


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