Skip to content

Commit

Permalink
#11732: Exclude _init_time from import form fields list
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremystretch committed Aug 1, 2023
1 parent cbf4b43 commit 7b998cf
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions netbox/netbox/views/generic/bulk_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from django.db import transaction, IntegrityError
from django.db.models import ManyToManyField, ProtectedError
from django.db.models.fields.reverse_related import ManyToManyRel
from django.forms import ModelMultipleChoiceField, MultipleHiddenInput
from django.forms import HiddenInput, ModelMultipleChoiceField, MultipleHiddenInput
from django.http import HttpResponse
from django.shortcuts import get_object_or_404, redirect, render
from django.urls import reverse
Expand Down Expand Up @@ -313,6 +313,13 @@ def prep_related_object_data(self, parent, data):
"""
return data

def _get_form_fields(self):
# Exclude any fields which use a HiddenInput widget
return {
name: field for name, field in self.model_form().fields.items()
if type(field.widget) is not HiddenInput
}

def _save_object(self, model_form, request):

# Save the primary object
Expand Down Expand Up @@ -430,7 +437,7 @@ def get(self, request):
return render(request, self.template_name, {
'model': self.model_form._meta.model,
'form': form,
'fields': self.model_form().fields,
'fields': self._get_form_fields(),
'return_url': self.get_return_url(request),
**self.get_extra_context(request),
})
Expand Down Expand Up @@ -475,7 +482,7 @@ def post(self, request):
return render(request, self.template_name, {
'model': model,
'form': form,
'fields': self.model_form().fields,
'fields': self._get_form_fields(),
'return_url': self.get_return_url(request),
**self.get_extra_context(request),
})
Expand Down

0 comments on commit 7b998cf

Please sign in to comment.