Custom Script - stuck at generating URL to specific id (Device,IPAddress, ..) #13527
-
Hi, sorry for bothering with this, but I'm currently stuck writing some hopefully helpful URLs for a simple custom script which should allow me to quickly rename a device and all related However, while I get the When looking at
and here I'm stuck. Anyone who could give me a nudge how to proceed? Thanks a lot in advance!
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 13 replies
-
The Netbox REST API, and the Django ORM used within custom scripts, are two completely separate things. Netbox provides a helper get_absolute_url to turn a model instance into its URL, although actually it's just a relative URL. For example, this is what I see in nbshell:
If you want an absolute URL, I believe you'll need to prepend the base yourself - e.g. by wrapping it in Note that if you use the logging functions within a custom script, these support Markdown rendering which means the log messages can easily contain clickable links. For example:
|
Beta Was this translation helpful? Give feedback.
The Netbox REST API, and the Django ORM used within custom scripts, are two completely separate things.
Netbox provides a helper get_absolute_url to turn a model instance into its URL, although actually it's just a relative URL. For example, this is what I see in nbshell: