I'm still new to Django and am trying to understand and implement the "fat model, skinny view" pattern. It makes sense to me that a model should be self contained for re-usability though I don't currently see the use case for this particular model.
The model is a virtual machine for one of many cloud vendors. I have a polymorphic base model, VirtualMachine
which defines all the fields. I also have a specific model, VirtualMachineVendor
which implements the vendor specific control function for VirtualMachine
. Examples would be vm_create()
or vm_delete
that handle the model creation or deletion as well as the management of the cloud resource.
The view mainly processes the request and sends that to the correct model method and preparing data for the template. I want to add functionality for creating a domain record using some independent python code which communicates with the cloud provider.
Question: Should the VirtualMachine
model call this domain creation method or should this be something the View calls? In general, should a model be calling other model methods within the same or different app, or should the model return control back to the view after a call?
I've also been trying to make sense of these SO Q&A making mention of a service layer for these types of methods:
Proper way to consume data from RESTFUL API in django
Separation of business logic and data access in django
Related question: is it fair then to say that fat models refer to the methods associated directly with manipulation of the model data?