1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Closes #10314: Move clone() method from NetBoxModel to CloningMixin

This commit is contained in:
jeremystretch
2022-09-13 14:36:37 -04:00
parent 87af94a7d2
commit 6a9274a95f
4 changed files with 19 additions and 20 deletions

View File

@@ -92,8 +92,17 @@ class CloningMixin(models.Model):
def clone(self):
"""
Return a dictionary of attributes suitable for creating a copy of the current instance. This is used for pre-
populating an object creation form in the UI.
Returns a dictionary of attributes suitable for creating a copy of the current instance. This is used for pre-
populating an object creation form in the UI. By default, this method will replicate any fields listed in the
model's `clone_fields` list (if defined), but it can be overridden to apply custom logic.
```python
class MyModel(NetBoxModel):
def clone(self):
attrs = super().clone()
attrs['extra-value'] = 123
return attrs
```
"""
attrs = {}