nautobot.apps.views
¶
Utilities for apps to implement UI views.
nautobot.apps.views.NautobotUIViewSet
¶
Bases: mixins.ObjectDetailViewMixin
, mixins.ObjectListViewMixin
, mixins.ObjectEditViewMixin
, mixins.ObjectDestroyViewMixin
, mixins.ObjectBulkDestroyViewMixin
, mixins.ObjectBulkCreateViewMixin
, mixins.ObjectBulkUpdateViewMixin
, mixins.ObjectChangeLogViewMixin
, mixins.ObjectNotesViewMixin
Nautobot BaseViewSet that is intended for UI use only. It provides default Nautobot functionalities such as
create()
, bulk_create()
, update()
, partial_update()
, bulk_update()
, destroy()
, bulk_destroy()
, retrieve()
notes()
, changelog()
and list()
actions.
Source code in nautobot/core/views/viewsets.py
nautobot.apps.views.ObjectBulkCreateViewMixin
¶
Bases: NautobotViewSetMixin
UI mixin to bulk create model instances.
Source code in nautobot/core/views/mixins.py
nautobot.apps.views.ObjectBulkDestroyViewMixin
¶
Bases: NautobotViewSetMixin
, BulkDestroyModelMixin
UI mixin to bulk destroy model instances.
Source code in nautobot/core/views/mixins.py
bulk_destroy(request, *args, **kwargs)
¶
Call perform_bulk_destroy(). The function exist to keep the DRF's get/post pattern of {action}/perform_{action}, we will need it when we transition from using forms to serializers in the UI. User should override this function to handle any actions as needed before bulk destroy.
Source code in nautobot/core/views/mixins.py
perform_bulk_destroy(request, **kwargs)
¶
request.POST "_delete": Function to render the user selection of objects in a table form/BulkDestroyConfirmationForm via Response that is passed to NautobotHTMLRenderer. request.POST "_confirm": Function to validate the table form/BulkDestroyConfirmationForm and to perform the action of bulk destroy. Render the form with errors if exceptions are raised.
Source code in nautobot/core/views/mixins.py
nautobot.apps.views.ObjectBulkUpdateViewMixin
¶
Bases: NautobotViewSetMixin
, BulkUpdateModelMixin
UI mixin to bulk update model instances.
Source code in nautobot/core/views/mixins.py
959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 |
|
bulk_update(request, *args, **kwargs)
¶
Call perform_bulk_update(). The function exist to keep the DRF's get/post pattern of {action}/perform_{action}, we will need it when we transition from using forms to serializers in the UI. User should override this function to handle any actions as needed before bulk update.
Source code in nautobot/core/views/mixins.py
perform_bulk_update(request, **kwargs)
¶
request.POST "_edit": Function to render the user selection of objects in a table form/BulkUpdateForm via Response that is passed to NautobotHTMLRenderer. request.POST "_apply": Function to validate the table form/BulkUpdateForm and to perform the action of bulk update. Render the form with errors if exceptions are raised.
Source code in nautobot/core/views/mixins.py
nautobot.apps.views.ObjectChangeLogViewMixin
¶
Bases: NautobotViewSetMixin
UI mixin to list a model's changelog queryset
Source code in nautobot/core/views/mixins.py
nautobot.apps.views.ObjectDestroyViewMixin
¶
Bases: NautobotViewSetMixin
, mixins.DestroyModelMixin
UI mixin to destroy a model instance.
Source code in nautobot/core/views/mixins.py
destroy(request, *args, **kwargs)
¶
request.GET: render the ObjectDeleteConfirmationForm which is passed to NautobotHTMLRenderer as Response. request.POST: call perform_destroy() which validates the form and perform the action of delete. Override to add more variables to Response
Source code in nautobot/core/views/mixins.py
perform_destroy(request, **kwargs)
¶
Function to validate the ObjectDeleteConfirmationForm and to delete the object.
Source code in nautobot/core/views/mixins.py
nautobot.apps.views.ObjectDetailViewMixin
¶
Bases: NautobotViewSetMixin
, mixins.RetrieveModelMixin
UI mixin to retrieve a model instance.
Source code in nautobot/core/views/mixins.py
retrieve(request, *args, **kwargs)
¶
Retrieve a model instance.
Source code in nautobot/core/views/mixins.py
nautobot.apps.views.ObjectEditViewMixin
¶
Bases: NautobotViewSetMixin
, mixins.CreateModelMixin
, mixins.UpdateModelMixin
UI mixin to create or update a model instance.
Source code in nautobot/core/views/mixins.py
727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 |
|
create(request, *args, **kwargs)
¶
request.GET: render the ObjectForm which is passed to NautobotHTMLRenderer as Response. request.POST: call perform_create() which validates the form and perform the action of create. Override to add more variables to Response.
Source code in nautobot/core/views/mixins.py
perform_create(request, *args, **kwargs)
¶
Function to validate the ObjectForm and to create a new object.
Source code in nautobot/core/views/mixins.py
perform_update(request, *args, **kwargs)
¶
Function to validate the ObjectEditForm and to update/partial_update an existing object.
Source code in nautobot/core/views/mixins.py
update(request, *args, **kwargs)
¶
request.GET: render the ObjectEditForm which is passed to NautobotHTMLRenderer as Response. request.POST: call perform_update() which validates the form and perform the action of update/partial_update of an existing object. Override to add more variables to Response.
Source code in nautobot/core/views/mixins.py
nautobot.apps.views.ObjectListViewMixin
¶
Bases: NautobotViewSetMixin
, mixins.ListModelMixin
UI mixin to list a model queryset
Source code in nautobot/core/views/mixins.py
599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 |
|
filter_queryset(queryset)
¶
Filter a query with request querystrings.
Source code in nautobot/core/views/mixins.py
list(request, *args, **kwargs)
¶
List the model instances.
Source code in nautobot/core/views/mixins.py
queryset_to_yaml()
¶
Export the queryset of objects as concatenated YAML documents.
Source code in nautobot/core/views/mixins.py
nautobot.apps.views.ObjectNotesViewMixin
¶
Bases: NautobotViewSetMixin
UI Mixin for an Object's Notes.
Source code in nautobot/core/views/mixins.py
nautobot.apps.views.ObjectView
¶
Bases: ObjectPermissionRequiredMixin
, View
Retrieve a single object for display.
queryset: The base queryset for retrieving the object template_name: Name of the template to use
Source code in nautobot/core/views/generic.py
get(request, *args, **kwargs)
¶
Generic GET handler for accessing an object.
Source code in nautobot/core/views/generic.py
get_extra_context(request, instance)
¶
Return any additional context data for the template.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
request |
Request
|
The current request |
required |
instance |
Model
|
The object being viewed |
required |
Returns:
Type | Description |
---|---|
dict
|
Additional context data |
Source code in nautobot/core/views/generic.py
get_template_name()
¶
Return self.template_name if set. Otherwise, resolve the template path by model app_label and name.