title: Django functions vs database functions
body: <p>What is the best way to implement functions while writing an app in django? For example, I'd like to have a function that would read some data from other tables, merge then into the result and update user score based on it.<br>
  I'm using postgresql database, so I can implement it as database function and use django to directly call this function.<br>
  I could also get all those values in python, implement is as django function.<br>
  Since the model is defined in django, I feel like I shouldn't define functions in the database construction but rather implement them in python. Also, if I wanted to recreate the database on another computer, I'd need to hardcode those functions and load them into database in order to do that.<br>
  On the other hand, if the database is on another computer such function would need to call database multiple times.  </p>
  
  <p>Which is preferred option when implementing an app in django?</p>
  
  <p>Also, how should I handle constraints, that I'd like the fields to have? Overloading the <code>save()</code> function or adding constraints to database fields by hand?</p>