AMACB
0
Q:

django updateview class

class YourView(generic.UpdateView):
	model			= YourModel
    fields			= ['your_fields']
    template_name	= 'your_template.html'
    success_url		= reverselazy('home')
0
###### views.py #####
from .models import Article
from .forms import  UpdateArticleForm
from django.views.generic import UpdateView
class ArticleUpdateView(UpdateView):
    model = Article
    form_class = UpdateArticleForm
    template_name = 'articles/create_article.html'
    
###### urls.py  ######
from .views import ArticleUpdateView
urlpatterns =[ 
  path('articles/<int:pk>/update/', ArticleUpdateView.as_view()),]
# pk is default value (for primary key of id of an instance of object
-1

New to Communities?

Join the community