Ingxaki ephambili ngeembono ze-django kukuba azikhusekanga. Oku kuthetha ukuba ukuba uhlaziya okanye ucima imbono kumsonto omnye, ayizukubonakala kweminye imisonto.
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 khowudi yimboniselo kwi-Django evumela umsebenzisi ukuba ahlaziye okanye acime into. Ukuba indlela yesicelo yi-'POST', into leyo iya kuhlaziywa. Ukuba indlela yesicelo ithi 'CIMA', into ke leyo iya kucinywa.
Uyicima njani iposi kunye nokucima ithegi
Kwi-Django, unokucima isithuba okanye ithegi ngokusebenzisa indlela yokucima () kwi-Post object.
Ukucima isithuba:
1. Kwiphaneli yolawulo yebhlog yakho, cofa iiPosts.
2. Kuludwe lweZithuba, cofa isithuba ofuna ukusicima.
3. Kwiphepha leenkcukacha zePosi, phantsi ko-"Cima le post?" cofa Ewe.
4. Kwiphepha lokuqinisekisa, cofa Cima.