mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Update device component bulk edit forms to use form_from_model()
This commit is contained in:
@@ -126,9 +126,13 @@ def add_blank_choice(choices):
|
||||
|
||||
def form_from_model(model, fields):
|
||||
"""
|
||||
Return a Form class with the specified fields from a model.
|
||||
Return a Form class with the specified fields derived from a model. This is useful when we need a form to be used
|
||||
for creating objects, but want to avoid the model's validation (e.g. for bulk create/edit functions). All fields
|
||||
are marked as not required.
|
||||
"""
|
||||
form_fields = fields_for_model(model, fields=fields)
|
||||
for field in form_fields.values():
|
||||
field.required = False
|
||||
|
||||
return type('FormFromModel', (forms.Form,), form_fields)
|
||||
|
||||
|
Reference in New Issue
Block a user