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.
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 oncustom_object_typewasn'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 theget_model_with_serializer()method instead of the simpleget_model().Let me know what you think about that.