1class YourView(generic.UpdateView):
2 model = YourModel
3 fields = ['your_fields']
4 template_name = 'your_template.html'
5 success_url = reverselazy('home')
1emp = Employee.objects.get(pk = emp_id)
2emp.name = 'Somename'
3emp.save()
4
1###### views.py #####
2from .models import Article
3from .forms import UpdateArticleForm
4from django.views.generic import UpdateView
5class ArticleUpdateView(UpdateView):
6 model = Article
7 form_class = UpdateArticleForm
8 template_name = 'articles/create_article.html'
9
10###### urls.py ######
11from .views import ArticleUpdateView
12urlpatterns =[
13 path('articles/<int:pk>/update/', ArticleUpdateView.as_view()),]
14# pk is default value (for primary key of id of an instance of object