This happens because _diff() in response.py returns False as the desired state matches its initial internal state, coming from the _init_cache list.
We've been here manytimes. Yes, I know I should have called .full_details() after the .save() to have the attributes fetched and populated again. Yes, I know pynetbox is not an ORM and it just abstracts API calls, but let's be honest, this whole way of working is highly misleading, especially for newbies.
Observed Behavior
I propose to:
mention this behavior in the documentation,
or add Api an option that makes pynetbox reload the object once it was saved or updated, like this: nb=pynetbox.api('http://127.0.0.1:8000', 'yada', always_reload=True)
or rename/alias this full_details() to reload() or something else that makes more sense
or have the Record update its own _init_cache. I know this is hard/impossible without getting back the object from NetBox and doing so would incur performance penalties; hence, I don't recommend it to be enabled by default.
pynetbox version
v7.0.1
NetBox version
v3.6.1
Python version
3.11
Steps to Reproduce
Consider this simple modifying of a given attribute:
Expected Behavior
This happens because
_diff()
inresponse.py
returnsFalse
as the desired state matches its initial internal state, coming from the_init_cache
list.We've been here many times. Yes, I know I should have called
.full_details()
after the.save()
to have the attributes fetched and populated again. Yes, I know pynetbox is not an ORM and it just abstracts API calls, but let's be honest, this whole way of working is highly misleading, especially for newbies.Observed Behavior
I propose to:
Api
an option that makespynetbox
reload the object once it was saved or updated, like this:nb=pynetbox.api('http://127.0.0.1:8000', 'yada', always_reload=True)
full_details()
toreload()
or something else that makes more senseRecord
update its own_init_cache
. I know this is hard/impossible without getting back the object from NetBox and doing so would incur performance penalties; hence, I don't recommend it to be enabled by default.