Generic Views¶
Warning
In new development, rather than implementing these individual class-based views, you will typically want to use NautobotUIViewSet (or its component mixin classes) as it enables similar functionality with less boilerplate code required.
ObjectView- Retrieve a single object for display.ObjectListView- List a series of objects.ObjectEditView- Create or edit a single object.ObjectDeleteView- Delete a single object.BulkCreateView- Create new objects in bulk.BulkDeleteView- Delete objects in bulk.BulkEditView- Edit objects in bulk.
Removed in version 2.2.0
BulkImportView is deprecated as it's been replaced by a system Job; it will be removed from the code base in Nautobot 3.0 and should not be used in any new development in the interim.
Once you define a view by subclassing any of the above generic classes, you must register it in your urls.py as usual. There are a few things to be aware of here:
- Reverse URL naming needs to follow a template of 
{modelname}_{method}where the model name is lowercased model class name frommodels.pyand method is the purpose of the view. E.g._list,_add,_edit. - The default rendering context for the 
ObjectListViewincludes some standardaction_buttonsfor interacting with the listed model. By default this view definesaction_buttons = ("add", "import", "export"). Theexportandimportactions are handled automatically byObjectListView, but theaddaction needs a corresponding view in order to work. In other words, if you implement anObjectListViewand do not override itsaction_buttons, you must also implement and register the correspondingObjectEditView. 
If you do not need ObjectEditView for your particular model, as an alternative you can simply update your ObjectListView subclass to overload the action buttons.  For example, action_buttons = ("import", "export") or if none are required action_buttons = ().