Where does business logic in a model method go in Django Rest Framework?
<p>I have 3 models that are related to each other with one-to-many relationships.</p>

<ul>
<li>Model A can have many instances of Model B.</li>
<li>Model A can have many instances of Model C.</li>
<li>Model B can have many instances of Model C.</li>
</ul>

<p>The idea is that a user would create an instance of Model A (like a stock portfolio) and then enter stock holdings (Model C). Where Model B fits in is that I want to run calculations/logic based on the stocks (Model C) in the portfolio (Model A) and using another class/model to keep track of things makes life easier, hence Model B.</p>

<p>I originally had the logic for these calculations in a Django view but read in <em>Two Scoops of Django</em> that business logic should be separated from views. As a result I moved the logic to a method of Model A (the portfolio) and now call that method from a view. This logic loops through the stock holdings and creates new instances of Model B, the results.</p>

<p>I am now interested in exploring django-rest-framework to provide an API to a javascript frontend (like Angular). I am guessing that I will not be able to have this kind of data manipulation within my REST interfaces. However, the result of this logic (data in Model B) needs to be visible via REST. Therefore, where does this type of calculation/logic go? </p>