mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-26 09:16:10 -06:00
adds full_clean in examples #11689
This commit is contained in:
parent
259d0e96f2
commit
3f56f13d84
@ -153,6 +153,7 @@ New objects can be created by instantiating the desired model, defining values f
|
||||
```
|
||||
>>> lab1 = Site.objects.get(pk=7)
|
||||
>>> myvlan = VLAN(vid=123, name='MyNewVLAN', site=lab1)
|
||||
>>> myvlan.full_clean()
|
||||
>>> myvlan.save()
|
||||
```
|
||||
|
||||
@ -169,6 +170,7 @@ To modify an existing object, we retrieve it, update the desired field(s), and c
|
||||
>>> vlan.name
|
||||
'MyNewVLAN'
|
||||
>>> vlan.name = 'BetterName'
|
||||
>>> vlan.full_clean()
|
||||
>>> vlan.save()
|
||||
>>> VLAN.objects.get(pk=1280).name
|
||||
'BetterName'
|
||||
|
@ -378,6 +378,7 @@ class NewBranchScript(Script):
|
||||
slug=slugify(data['site_name']),
|
||||
status=SiteStatusChoices.STATUS_PLANNED
|
||||
)
|
||||
site.full_clean()
|
||||
site.save()
|
||||
self.log_success(f"Created new site: {site}")
|
||||
|
||||
@ -391,6 +392,7 @@ class NewBranchScript(Script):
|
||||
status=DeviceStatusChoices.STATUS_PLANNED,
|
||||
device_role=switch_role
|
||||
)
|
||||
switch.full_clean()
|
||||
switch.save()
|
||||
self.log_success(f"Created new switch: {switch}")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user