Home > Back-end >  hwo to fetch upper data and then delete in one action in Django?
hwo to fetch upper data and then delete in one action in Django?

Time:07-25

I just want to fetch the upper data only and then delete it in one action. I tried this code:

`def Data(request):
     data =  Plan.objects.get(id = 1)
     data.delete()
     context = {'data':data}    
     return render(request,'data.html',context)`

But didn't work.

see Database column

CodePudding user response:

I don't understand, what is not works. Try to write a little bit more about your problem. Probably this can help:

def Data(request):
     data =  Plan.objects.get(id = 1)
     Plan.objects.filter(id = 1).delete()
     return render(request,'data.html',{'data':data})`
  • Related