해결됨: django view…2C 업데이트 또는 삭제 – GET%2C POST%2C GET%2C PUT%2C DELETE%29

django 뷰의 주요 문제는 스레드로부터 안전하지 않다는 것입니다. 즉, 한 스레드에서 보기를 업데이트하거나 삭제하면 다른 스레드에 반영되지 않습니다.

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

이 코드는 사용자가 개체를 업데이트하거나 삭제할 수 있는 Django의 보기입니다. 요청 방법이 'POST'인 경우 개체가 업데이트됩니다. 요청 방식이 'DELETE'인 경우 객체가 삭제됩니다.

게시물 삭제 및 태그 삭제 방법

Django에서는 Post 객체의 delete() 메서드를 사용하여 게시물이나 태그를 삭제할 수 있습니다.

게시물을 삭제하려면:

1. 블로그 관리자 패널에서 게시물을 클릭합니다.

2. 게시물 목록에서 삭제할 게시물을 클릭합니다.

3. 게시물 세부정보 페이지의 "이 게시물을 삭제하시겠습니까?" 예를 클릭합니다.

4. 확인 페이지에서 삭제를 클릭합니다.

관련 게시물:

코멘트 남김