Skip to content

Conversation

@anshulkamath
Copy link
Contributor

Fixes: #251

custom objects are indexed via the view's url, which is derived from the custom object's slug. the existing bulk import form looked up the custom object by name though, rather than slug. this commit fixes that bad lookup field. the bulk import and bulk delete forms already do this.

additionally, we add a slug uniqueness constraint on the custom object type for additional safeguarding

custom objects are indexed via the view's url, which is derived from the
custom object's slug. the existing bulk import form looked up the custom
object by name though, rather than slug. this commit fixes that bad
lookup field. the bulk import and bulk delete forms already do this.

additionally, we add a slug uniqueness constraint on the custom object
type for additional safeguarding
@bctiemann
Copy link
Contributor

Thanks @anshulkamath . Sanity check, does this need a migration?

@anshulkamath
Copy link
Contributor Author

@bctiemann great catch. I've updated the PR with the migration

@arthanson arthanson requested a review from bctiemann October 20, 2025 15:29
"A Custom Object Type with this name already exists."
),
),
models.UniqueConstraint(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary if we already have unique=True on the slug field? I believe it's implicit unless you really want to override the error message.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed that one. Overriding is not necessary then.

@@ -0,0 +1,20 @@
# Generated by Django 5.2.7 on 2025-10-20 13:24
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this UniqueConstraint is necessary (I don't think it is), could you please rename this migration to something a bit more informative/less unwieldy (following the usual pattern in NetBox core migrations)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the unique constraint

@bctiemann bctiemann merged commit d5d96ae into netboxlabs:main Oct 20, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bulk Import for Custom Objects is Broken

2 participants