def approve(request, *args, **kwargs): if request.user.is_authenticated and request.user.is_superuser: id_inc = kwargs["id_inc"] qs = pending.objects.all() for obj in qs: # print(obj.id_inc) if int(obj.id_inc) == int(id_inc): # print("heyyyyy") new_obj = Product() new_obj.user_name = obj.user_name new_obj.category = obj.category new_obj.name = obj.name new_obj.desc = obj.desc new_obj.contact_email = obj.contact_email new_obj.contact_phone = obj.contact_phone new_obj.address = obj.address new_obj.image = obj.image new_obj.price = obj.price new_obj.save() obj.delete() return HttpResponseRedirect('../../pending') break return HttpResponseRedirect('../../pending') else: return HttpResponseRedirect('../../../')