Solved: django view…2C update or delete – GET%2C POST%2C GET%2C PUT%2C DELETE%29

The main problem with django views is that they are not thread-safe. This means that if you update or delete a view from one thread, it will not be reflected in other threads.


I am trying to create a view in Django that will allow me to either update or delete an object. I have been able to get the view to work for either updating or deleting, but not both. For example, if I use the following code, I can update an object:

def my_view(request): if request.method == 'POST': # do something return HttpResponseRedirect('/success/') else: # do something else return render_to_response('my_template.html', {}, context_instance=RequestContext(request))

However, if I try to add a DELETE method, the view no longer works:

def my_view(request): if request.method == 'POST': # do something return HttpResponseRedirect('/success/') elif request.method == 'DELETE': # do something else return render_to_response('my_template.html', {}, context_instance=RequestContext(request))

This code is a view in Django that allows the user to either update or delete an object. If the request method is ‘POST’, then the object will be updated. If the request method is ‘DELETE’, then the object will be deleted.

How to delete post and delete tag

In Django, you can delete a post or a tag by using the delete() method on the Post object.

To delete a post:

1. In your blog’s admin panel, click Posts.

2. In the Posts list, click the post you want to delete.

3. On the Post details page, under “Delete this post?” click Yes.

4. On the confirmation page, click Delete.

Related posts:

Leave a Comment