Re: models.CalculatedField feature

2017-11-16 Thread ilya . kazakevich
Thank you for your intereset this on feature. I belive this functionality should not delegete everything to database: one of the cooliest Django features is that models do not require database: they could be just storage of *business* logic (that is why we call them *fat*). I can even fill my

Re: models.CalculatedField feature

2017-11-16 Thread Tom Forbes
I think without client-side Python execution of these functions it greatly limits the use of this feature. In the cases I've seen you have a bunch of `qs.filter(age__gt=18)` scattered around everywhere and a separate `can_drink` function of property. Without the `can_drink` function returning the

Re: models.CalculatedField feature

2017-11-16 Thread Sjoerd Job Postmus
I disagree with not being able to calculate it locally (without the database): such a calculation depends on other fields. What if a dependent field is updated, but the object is not yet saved. What should the value be?>>> c.age, c.is_adult17, False>>> c.age = 40>>> c.age, c.is_adult40, FalseWould

Re: models.CalculatedField feature

2017-11-16 Thread Marc Tamlyn
I like the idea, and have a number of concrete use cases I would use it for. In one case I even have a custom manager which always applies a particular `.annotate()` already, so it can be filtered and accessed on the model. I am inclined to agree with Shai that the fully database version should