diff --git a/netbox/netbox/views/generic/object_views.py b/netbox/netbox/views/generic/object_views.py index 19401f79a..7617e0402 100644 --- a/netbox/netbox/views/generic/object_views.py +++ b/netbox/netbox/views/generic/object_views.py @@ -328,6 +328,12 @@ class ObjectEditView(GetReturnURLMixin, BaseObjectView): """ return obj + def get_extra_addanother_params(self, request): + """ + Return a dictionary of extra parameters to use on the Add Another button. + """ + return {} + # # Request handlers # @@ -403,6 +409,7 @@ class ObjectEditView(GetReturnURLMixin, BaseObjectView): # If cloning is supported, pre-populate a new instance of the form params = prepare_cloned_fields(obj) + params.update(self.get_extra_addanother_params(request)) if params: if 'return_url' in request.GET: params['return_url'] = request.GET.get('return_url') diff --git a/netbox/tenancy/views.py b/netbox/tenancy/views.py index 9a2fe6ab9..e582c15d1 100644 --- a/netbox/tenancy/views.py +++ b/netbox/tenancy/views.py @@ -1,4 +1,5 @@ from django.contrib.contenttypes.models import ContentType +from django.http import QueryDict from django.shortcuts import get_object_or_404 from circuits.models import Circuit @@ -365,6 +366,12 @@ class ContactAssignmentEditView(generic.ObjectEditView): instance.object = get_object_or_404(content_type.model_class(), pk=request.GET.get('object_id')) return instance + def get_extra_addanother_params(self, request): + return { + 'content_type': request.GET.get('content_type'), + 'object_id': request.GET.get('object_id'), + } + class ContactAssignmentDeleteView(generic.ObjectDeleteView): queryset = ContactAssignment.objects.all() diff --git a/netbox/utilities/utils.py b/netbox/utilities/utils.py index 1dece76c8..69ab615fc 100644 --- a/netbox/utilities/utils.py +++ b/netbox/utilities/utils.py @@ -285,7 +285,7 @@ def prepare_cloned_fields(instance): """ # Generate the clone attributes from the instance if not hasattr(instance, 'clone'): - return QueryDict() + return QueryDict(mutable=True) attrs = instance.clone() # Prepare querydict parameters