Skip to content

Commit ca1dd95

Browse files
authored
Merge pull request #280 from netboxlabs/276-fix-importing-custom-objects-tip
2 parents cdcd244 + fcae4bd commit ca1dd95

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

docs/index.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,17 @@
1010
1111

1212
> [!TIP]
13-
> If you are using Custom Objects with Custom Scripts or Plugins you need to use Django's `AppConfig.get_model` to retrieve Custom Object Types: [https://docs.djangoproject.com/en/5.2/ref/applications/#django.apps.AppConfig.get_model](https://docs.djangoproject.com/en/5.2/ref/applications/#django.apps.AppConfig.get_model)
14-
> Pass in the plugin name (`netbox_custom_objects`) and the name of the Custom Object (e.g. `dhcp_scope`) to return the correct object.
13+
> If you are using Custom Objects with Custom Scripts or Plugins you will need to use the following method to import and instantiate a Custom Object as a class that will behave like a standard Django model:
14+
> ```python
15+
> from netbox_custom_objects.models import CustomObjectType
16+
>
17+
> custom_object_type = CustomObjectType.objects.get(name="cat")
18+
> Cat = custom_object_type.get_model()
19+
> ```
20+
> ```python
21+
> In [21]: Cat.objects.count()
22+
> Out[21]: 3
23+
> ```
1524
1625
## Features
1726

0 commit comments

Comments
 (0)