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

Ordering of DCIM models break dumpdata/loaddata functionality #3849

Closed
jeremystretch opened this issue Jan 6, 2020 · 0 comments
Closed

Ordering of DCIM models break dumpdata/loaddata functionality #3849

jeremystretch opened this issue Jan 6, 2020 · 0 comments
Assignees
Labels
status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@jeremystretch
Copy link
Member

Environment

  • Python version: 3.6.8
  • NetBox version: 2.6.11

Steps to Reproduce

  1. Create at least one cable terminated to a power feed
  2. Export existing data with ./manage.py dumpdata -o <filename> --natural-foreign --natural-primary --indent 4 --format json
  3. Load the JSON-formatted data into a new database with ./manage.py loaddata <filename>

Expected Behavior

All data should be imported successfully

Observed Behavior

An AttrbiuteError is raised:

AttributeError: Problem installing fixture '/home/jstretch/netbox/netbox/../demo_data.json': 'NoneType' object has no attribute 'cable'

This is because Django is exporting Cables prior to exporting PowerFeeds. Upon import, Django is attempting to create cables to terminations that don't yet exist, hence the exception.

Presumably, this can be fixed by moving the Cable model definition so that it comes after PowerFeed in models.py.

@jeremystretch jeremystretch added type: bug A confirmed report of unexpected behavior in the application status: accepted This issue has been accepted for implementation labels Jan 6, 2020
@jeremystretch jeremystretch self-assigned this Jan 9, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Apr 15, 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: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

1 participant