How to add tags to new interface in custom script #19733
krasotinpa
started this conversation in
General
Replies: 2 comments
-
Hi there, The NetBox Customizations repository has some excellent, real-world examples you can follow — in particular, take a look at For your use-case, you can streamline validation and tagging like this: class CreateInterface(Script):
# … other fields, args, etc.
def run(self, data, commit):
# Instantiate the interface
new_if = Interface(
device=data["device"],
name=data["interface_name"],
)
# Validate all fields before saving
new_if.full_clean()
new_if.save()
# Apply tags in one call
new_if.tags.set(data["tags"]) A few tips:
Hope that helps |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thank you, @pheus ! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi!
Please advise me how to add tags to new interface wich I create in custom script?
Should I create interface first and then add tags? Or there is a way do it on Interface object ctreation?
This code works
Beta Was this translation helpful? Give feedback.
All reactions