निराकरण: django view…2C अपडेट करा किंवा हटवा – GET%2C POST%2C GET%2C PUT%2C हटवा%29

जॅंगो दृश्यांची मुख्य समस्या ही आहे की ते थ्रेड-सेफ नाहीत. याचा अर्थ असा की जर तुम्ही एका थ्रेडमधून एखादे दृश्य अपडेट केले किंवा हटवले तर ते इतर थ्रेडमध्ये परावर्तित होणार नाही.

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' असल्यास, ऑब्जेक्ट हटविला जाईल.

पोस्ट कसा हटवायचा आणि टॅग कसा हटवायचा

जॅंगोमध्ये, तुम्ही पोस्ट ऑब्जेक्टवर डिलीट() पद्धत वापरून पोस्ट किंवा टॅग हटवू शकता.

पोस्ट हटवण्यासाठी:

1. तुमच्या ब्लॉगच्या प्रशासन पॅनेलमध्ये, पोस्ट वर क्लिक करा.

2. पोस्ट सूचीमध्ये, तुम्हाला हटवायचे असलेल्या पोस्टवर क्लिक करा.

3. पोस्ट तपशील पृष्ठावर, “ही पोस्ट हटवा?” अंतर्गत होय क्लिक करा.

4. पुष्टीकरण पृष्ठावर, हटवा क्लिक करा.

संबंधित पोस्ट:

एक टिप्पणी द्या