On admin page , I created a delete entries button .
I clicked and it asked me yes or no .I click yes but no effect .
(The whole system designed with Django )
How to solve ?
On A.html
<button class="btn btn-danger btn-sm" style = "padding: 2px 4px;" id="delete"onclick = "Del('')">Delete</button>
<script>
function Del(id){
console.log("delet*********")
swal({
title: "Are you sure?",
text: "To Delete this Entry!",
icon: "warning",
buttons: ["No", "Yes"],
closeOnClickOutside: false,
dangerMode: true,
})
.then((willDelete) => {
if (willDelete) {
$.ajax({
method : "POST",
url : "/delete_lost_item/",
data : {
'id':id,
},
success : function(response){
if (response == "success"){
swal("Entry has been Deleted..!", {
icon: "success",
button: "Ok",
closeOnClickOutside: false,
}).then(function() {
location.reload();
});
}
}
})
}
});
}
</script>
on Table Lost_Item
class Lost_Item_table(admin.ModelAdmin):
list_display = ['id','lebal','title','brand','species'...]
URL.PY
url(r'^delete_lost_item/$',delete_lost_item, name='delete_lost_item'),
Aucun commentaire:
Enregistrer un commentaire