Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bulk import custom fields #568

Closed
rgstori opened this issue Sep 21, 2016 · 7 comments · Fixed by #4050
Closed

Bulk import custom fields #568

rgstori opened this issue Sep 21, 2016 · 7 comments · Fixed by #4050
Assignees
Labels
status: accepted This issue has been accepted for implementation type: feature Introduction of new functionality to the application

Comments

@rgstori
Copy link

rgstori commented Sep 21, 2016

I'd like the possibility, one some custom fields are defined, to have them importable in bulk.

@jeremystretch jeremystretch added the type: feature Introduction of new functionality to the application label Sep 22, 2016
@candlerb
Copy link
Contributor

Example use case:

I have added a custom field "FQDN" to the "ipam > IP Address" model. I'm importing a load of IP addresses in CSV format, and I want to import the corresponding FQDNs at the same time.

@paravoid
Copy link
Contributor

I had the same need for the DCIM/Device model. I very naively did:

--- a/netbox/dcim/forms.py
+++ b/netbox/dcim/forms.py
@@ -777,7 +777,7 @@ class DeviceForm(BootstrapMixin, TenancyForm, CustomFieldForm):
             self.initial['rack'] = self.instance.parent_bay.device.rack_id
 
 
-class BaseDeviceCSVForm(forms.ModelForm):
+class BaseDeviceCSVForm(BootstrapMixin, CustomFieldForm):
     device_role = forms.ModelChoiceField(
         queryset=DeviceRole.objects.all(),
         to_field_name='name',

…andi it seems to have done the trick: a new CSV field, prefixed with cf_ (in my case, cf_ticket) appeared on the form. I tried importing while populating that and it just worked :)

Are there complexities I haven't encountered yet or is it just that simple?

@benclaussen
Copy link

benclaussen commented Jan 24, 2018

@paravoid I attempted this same thing in the IPAM forms.py (netbox/ipam/forms.py) the field appeared... however it also broke the API. When I attempted to load the API docs, I received an Internal Server Error and the error emails stated

Internal Server Error: /api/docs/

KeyError at /api/docs/
'en-us'

...

I don't know for certain if the API actually broke or if it was just Swagger docs...but something was unhappy.

Netbox v2.2.8
Python v2.7.12
Ubuntu server 16.04.3 LTS

@jeremystretch jeremystretch added the status: accepted This issue has been accepted for implementation label Jan 26, 2018
@netbox-community netbox-community deleted a comment from CDawson1 Jul 17, 2018
wmfgerrit pushed a commit to wikimedia/operations-software-netbox that referenced this issue Oct 17, 2018
This reverts commit 07a7fac.
We've now migrated to Netbox and we don't need anymore this local
change and it's easier to upgrade the repository to the latest upstream
version without local modifications.

The upstream issue for this is:
netbox-community/netbox#568

Bug: T205896
Change-Id: Id71e0e2ed1e817d18bb5c67575e294625b266c8b
wmfgerrit pushed a commit to wikimedia/operations-software-netbox-deploy that referenced this issue Oct 17, 2018
* Update netbox from branch 'master'
  to b6a2931e0dc5fa11a2004dad7acc812863aa7555
  - Revert "Allow custom fields in the Device CSV form"
    
    This reverts commit 07a7facdf44d6c86cd045c0a336541b37cb4d718.
    We've now migrated to Netbox and we don't need anymore this local
    change and it's easier to upgrade the repository to the latest upstream
    version without local modifications.
    
    The upstream issue for this is:
    netbox-community/netbox#568
    
    Bug: T205896
    Change-Id: Id71e0e2ed1e817d18bb5c67575e294625b266c8b
@anthonyeden
Copy link

I'm going to have a go at implementing this, and do a pull request. I'm thinking it would also make sense to export custom fields via the various CSV templates.

Does this sound good? Is it within scope of this ticket, or should I create a new one?

@anthonyeden
Copy link

I've created a draft pull request to address Custom Field importing and exporting: #2949

Would a project maintainer be able to take a look and provide feedback?

@iDemonix
Copy link

iDemonix commented May 9, 2019

After creating a very large CSV of data, mainly custom field data, we've also discovered this functionality isn't yet there.

Thanks for doing the work @anthonyeden, does your PR encompass imports for just Devices? Or does it cover Virtual Machines etc also?

@anthonyeden
Copy link

Hi @iDemonix,

This pull request now encompasses all different CSV Import models. Would you mind testing it for me and reporting back here?

@netbox-community netbox-community deleted a comment from bT0mm Jan 23, 2020
jeremystretch added a commit that referenced this issue Jan 29, 2020
Fixes #568: CSV import/export of custom fields
@jeremystretch jeremystretch self-assigned this Jan 29, 2020
jeremystretch added a commit that referenced this issue Jan 30, 2020
…port

Closes #568: Extend CSV import to support custom fields
@lock lock bot locked as resolved and limited conversation to collaborators May 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation type: feature Introduction of new functionality to the application
Projects
None yet
7 participants