deleteview in django code example
Example 1: django deleteview class
from django.urls import reverse_lazy
from django.views.generic.edit import DeleteView
from myapp.models import Author
class AuthorDelete(DeleteView):
model = Author
success_url = reverse_lazy('author-list')
<form method="post">{% csrf_token %}
<p>Are you sure you want to delete "{{ object }}"?</p>
<input type="submit" value="Confirm">
</form>
Example 2: django edit model data in django view
emp = Employee.objects.get(pk = emp_id)
emp.name = 'Somename'
emp.save()