From 503e781f48b8337d15a7a5aaa92cde386115cfac Mon Sep 17 00:00:00 2001 From: Arthur Hanson Date: Thu, 26 Sep 2024 09:44:32 -0700 Subject: [PATCH] 17476 Upgrade to Django 5.1 --- netbox/extras/forms/bulk_import.py | 6 +++--- netbox/ipam/forms/model_forms.py | 18 +++++++++--------- netbox/vpn/forms/model_forms.py | 14 +++++++------- requirements.txt | 2 +- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/netbox/extras/forms/bulk_import.py b/netbox/extras/forms/bulk_import.py index 55c9cd764..6e2fe6d63 100644 --- a/netbox/extras/forms/bulk_import.py +++ b/netbox/extras/forms/bulk_import.py @@ -192,7 +192,7 @@ class EventRuleImportForm(NetBoxModelImportForm): label=_('Event types'), help_text=_('The event type(s) which will trigger this rule') ) - action_object = forms.CharField( + action_object_key = forms.CharField( label=_('Action object'), required=True, help_text=_('Webhook name or script as dotted path module.Class') @@ -202,13 +202,13 @@ class EventRuleImportForm(NetBoxModelImportForm): model = EventRule fields = ( 'name', 'description', 'enabled', 'conditions', 'object_types', 'event_types', 'action_type', - 'action_object', 'comments', 'tags' + 'action_object_key', 'comments', 'tags' ) def clean(self): super().clean() - action_object = self.cleaned_data.get('action_object') + action_object = self.cleaned_data.get('action_object_key') action_type = self.cleaned_data.get('action_type') if action_object and action_type: # Webhook diff --git a/netbox/ipam/forms/model_forms.py b/netbox/ipam/forms/model_forms.py index f98f8b24f..fd9dddc2f 100644 --- a/netbox/ipam/forms/model_forms.py +++ b/netbox/ipam/forms/model_forms.py @@ -574,7 +574,7 @@ class VLANGroupForm(NetBoxModelForm): required=False, label=_('Scope type') ) - scope = DynamicModelChoiceField( + scope_key = DynamicModelChoiceField( label=_('Scope'), queryset=Site.objects.none(), # Initial queryset required=False, @@ -585,13 +585,13 @@ class VLANGroupForm(NetBoxModelForm): fieldsets = ( FieldSet('name', 'slug', 'description', 'tags', name=_('VLAN Group')), FieldSet('vid_ranges', name=_('Child VLANs')), - FieldSet('scope_type', 'scope', name=_('Scope')), + FieldSet('scope_type', 'scope_key', name=_('Scope')), ) class Meta: model = VLANGroup fields = [ - 'name', 'slug', 'description', 'vid_ranges', 'scope_type', 'scope', 'tags', + 'name', 'slug', 'description', 'vid_ranges', 'scope_type', 'scope_key', 'tags', ] def __init__(self, *args, **kwargs): @@ -599,7 +599,7 @@ class VLANGroupForm(NetBoxModelForm): initial = kwargs.get('initial', {}) if instance is not None and instance.scope: - initial['scope'] = instance.scope + initial['scope_key'] = instance.scope kwargs['initial'] = initial super().__init__(*args, **kwargs) @@ -608,15 +608,15 @@ class VLANGroupForm(NetBoxModelForm): try: scope_type = ContentType.objects.get(pk=scope_type_id) model = scope_type.model_class() - self.fields['scope'].queryset = model.objects.all() - self.fields['scope'].widget.attrs['selector'] = model._meta.label_lower - self.fields['scope'].disabled = False - self.fields['scope'].label = _(bettertitle(model._meta.verbose_name)) + self.fields['scope_key'].queryset = model.objects.all() + self.fields['scope_key'].widget.attrs['selector'] = model._meta.label_lower + self.fields['scope_key'].disabled = False + self.fields['scope_key'].label = _(bettertitle(model._meta.verbose_name)) except ObjectDoesNotExist: pass if self.instance and scope_type_id != self.instance.scope_type_id: - self.initial['scope'] = None + self.initial['scope_key'] = None def clean(self): super().clean() diff --git a/netbox/vpn/forms/model_forms.py b/netbox/vpn/forms/model_forms.py index a17ca9a5e..0d2e8c012 100644 --- a/netbox/vpn/forms/model_forms.py +++ b/netbox/vpn/forms/model_forms.py @@ -235,7 +235,7 @@ class TunnelTerminationForm(NetBoxModelForm): selector=True, label=_('Device') ) - termination = DynamicModelChoiceField( + termination_key = DynamicModelChoiceField( queryset=Interface.objects.all(), label=_('Tunnel interface'), query_params={ @@ -252,13 +252,13 @@ class TunnelTerminationForm(NetBoxModelForm): ) fieldsets = ( - FieldSet('tunnel', 'role', 'type', 'parent', 'termination', 'outside_ip', 'tags'), + FieldSet('tunnel', 'role', 'type', 'parent', 'termination_key', 'outside_ip', 'tags'), ) class Meta: model = TunnelTermination fields = [ - 'tunnel', 'role', 'termination', 'outside_ip', 'tags', + 'tunnel', 'role', 'termination_key', 'outside_ip', 'tags', ] def __init__(self, *args, initial=None, **kwargs): @@ -273,8 +273,8 @@ class TunnelTerminationForm(NetBoxModelForm): self.fields['parent'].label = _('Virtual Machine') self.fields['parent'].queryset = VirtualMachine.objects.all() self.fields['parent'].widget.attrs['selector'] = 'virtualization.virtualmachine' - self.fields['termination'].queryset = VMInterface.objects.all() - self.fields['termination'].widget.add_query_params({ + self.fields['termination_key'].queryset = VMInterface.objects.all() + self.fields['termination_key'].widget.add_query_params({ 'virtual_machine_id': '$parent', }) self.fields['outside_ip'].widget.add_query_params({ @@ -283,13 +283,13 @@ class TunnelTerminationForm(NetBoxModelForm): if self.instance.pk: self.fields['parent'].initial = self.instance.termination.parent_object - self.fields['termination'].initial = self.instance.termination + self.fields['termination_key'].initial = self.instance.termination def clean(self): super().clean() # Set the terminated object - self.instance.termination = self.cleaned_data.get('termination') + self.instance.termination = self.cleaned_data.get('termination_key') class IKEProposalForm(NetBoxModelForm): diff --git a/requirements.txt b/requirements.txt index c3d87e52f..e3a7c93f8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -Django==5.0.9 +Django==5.1.1 django-cors-headers==4.4.0 django-debug-toolbar==4.4.6 django-filter==24.3