Inkinga enkulu ngokubuka kwe-django ukuthi ayiphephile ngochungechunge. Lokhu kusho ukuthi uma ubuyekeza noma ususa ukubuka kochungechunge olulodwa, ngeke kubonakale kolunye uchungechunge.
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))
Le khodi iwukubuka ku-Django okuvumela umsebenzisi ukuthi abuyekeze noma asuse into. Uma indlela yesicelo ithi 'THUMELA', into izobuyekezwa. Uma indlela yesicelo ithi 'SUSA', into izosuswa.
Ungakususa kanjani okuthunyelwe nokususa ithegi
Ku-Django, ungasusa iposi noma umaka ngokusebenzisa indlela ethi delete() entweni ethi Thumela.
Ukuze ususe okuthunyelwe:
1. Kuphaneli yokulawula yebhulogi yakho, chofoza Okuthunyelwe.
2. Ohlwini Lokuthunyelwe, chofoza okuthunyelwe ofuna ukukususa.
3. Ekhasini Lemininingwane Yokuthunyelwe, ngaphansi kokuthi “Susa lokhu okuthunyelwe?” chofoza Yebo.
4. Ekhasini lokuqinisekisa, chofoza okuthi Susa.