Adds full_clean in examples (#12527)

* adds full_clean in examples #11689

* removes extra info
This commit is contained in:
Abhimanyu Saharan
2023-05-09 18:01:50 +05:30
committed by GitHub
parent 344c733cd7
commit 0aa0e2a363
2 changed files with 4 additions and 6 deletions

View File

@@ -153,15 +153,10 @@ 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()
```
Alternatively, the above can be performed as a single operation. (Note, however, that `save()` does _not_ return the new instance for reuse.)
```
>>> VLAN(vid=123, name='MyNewVLAN', site=Site.objects.get(pk=7)).save()
```
To modify an existing object, we retrieve it, update the desired field(s), and call `save()` again.
```
@@ -169,6 +164,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'