Skip to content

Custom Script - stuck at generating URL to specific id (Device,IPAddress, ..) #13527

Discussion options

You must be logged in to vote

However, while I get the url attribute when I query via cURL I don't seem to get this information directly within the custom script.

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:

/opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py nbshell
### NetBox interactive shell (netbox3)
### Python 3.8.10 | Django 4.1.10 | NetBox 3.5.8
### lsmodels() will show available models. Use help(<model>) for more info.
>>> ip = IPAddress.objects.first()
>>> ip.get_absolute_url()…

Replies: 1 comment 13 replies

Comment options

You must be logged in to vote
13 replies
@carsten-AEI
Comment options

@candlerb
Comment options

@candlerb
Comment options

@carsten-AEI
Comment options

@candlerb
Comment options

Answer selected by carsten-AEI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants