sweetalert.

go to :
https://sweetalert.js.org/guides/
Do this
from django.contrib import messages
def detail(request, movie_id):
movie=Movie.objects.get(id=movie_id)
if request.method=='POST':
movie=Movie.objects.get(id=movie_id)
movie.delete()
messages.success(request, 'Movie deleted successfully !')
return redirect('/')
return render(request, "detail.html", {'movie': movie})
add this code to redirected page!
index.html
<!-- sweetalert -->
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
<script>
{% for msg in messages %}
swal("Good job!", "{{msg}}", "success");
{% endfor %}
</script>



No comments