Django, API, REST, Generic views. GitHub Next Previous. Method, which is similar to the update method, except that all fields for the update will be optional. This allows support for HTTP PATCH requests. If an object is. ' Apply this mixin to any view or viewset to get multiple field filtering based on a `lookupfields` attribute.
![]()
CreateView class django.views.generic.edit. CreateViewA view that displays a form for creating an object, redisplaying the formwith validation errors (if there are any) and saving the object.Ancestors (MRO)This view inherits methods and attributes from the following views:. django.views.generic.edit.BaseCreateView.Attributes templatenamesuffixThe CreateView page displayed to a GET request uses atemplatenamesuffix of 'form'. Forexample, changing this attribute to 'createform' for a viewcreating objects for the example Author model would cause thedefault templatename to be 'myapp/authorcreateform.html'. ObjectWhen using CreateView you have access to self.object, which isthe object being created. If the object hasn’t been created yet, thevalue will be None.Example myapp/views.py.
UpdateView class django.views.generic.edit. UpdateViewA view that displays a form for editing an existing object, redisplayingthe form with validation errors (if there are any) and saving changes tothe object.
This uses a form automatically generated from the object’smodel class (unless a form class is manually specified).Ancestors (MRO)This view inherits methods and attributes from the following views:. django.views.generic.edit.BaseUpdateView.Attributes templatenamesuffixThe UpdateView page displayed to a GET request uses atemplatenamesuffix of 'form'. Forexample, changing this attribute to 'updateform' for a viewupdating objects for the example Author model would cause thedefault templatename to be 'myapp/authorupdateform.html'. ObjectWhen using UpdateView you have access to self.object, which isthe object being updated.Example myapp/views.py. DeleteView class django.views.generic.edit.
DeleteViewA view that displays a confirmation page and deletes an existing object.The given object will only be deleted if the request method is POST. Ifthis view is fetched via GET, it will display a confirmation page thatshould contain a form that POSTs to the same URL.Ancestors (MRO)This view inherits methods and attributes from the following views:. django.views.generic.edit.BaseDeleteView.
django.views.generic.detail.BaseDetailView.Attributes templatenamesuffixThe DeleteView page displayed to a GET request uses atemplatenamesuffix of 'confirmdelete'. Forexample, changing this attribute to 'checkdelete' for a viewdeleting objects for the example Author model would cause thedefault templatename to be 'myapp/authorcheckdelete.html'.Example myapp/views.py.Contents.Browse. Prev:. Next:.You are here:. Generic editing viewsGetting help Try the FAQ — it's got answers to many common questions., or Handy when looking for specific information.
![]()
Search for information in the archives of the django-users mailing list, or post a question. Ask a question in the #django IRC channel, or search the IRC logs to see if it’s been asked before. Report bugs with Django or Django documentation in our ticket tracker. Download:Offline (Django 3.0): Provided.
![]() Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
March 2023
Categories |