Skip to content

Update the Custom Scripts documentation Tip to recommend get_model_with_serializer() method instead of get_model() #466

@mathieued

Description

@mathieued

Change Type

Correction

Proposed Changes

Hello,

I would suggest to edit the documentation section where the Tip for using Custom Objects within Custom Scripts & Plugins lies.

I had a hard time figuring out that the default get_model() method on custom_object_type wasn't importing the serializer of the same COT.
--> see Documentation Line
--> When using this import, it generated an error when trying to use the save() method on this Custom Object, because it wasn't finding the Serializer for the Table1Model class.

The error generated was as below:
Could not determine serializer for netbox_custom_objects.Table1Model with prefix ...

After searching in code, I found out that the CustomObjectType class has a method defined called get_model_with_serializer(). Using this method obviously solved my problem.

As a lot of Custom Scripts importing a COT will be used at some point to update data in a specific CO - and therefore using the save() method after modification - I would say that it makes sense to encourage people to use the get_model_with_serializer() method instead of the simple get_model().

Let me know what you think about that.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions