This question is a bit subjective, but here are my two cents:
- The business logic for changing multiple objects at the same time should go to the manager.
- ,
MyModel.objects.create_complex(foo, bar) - - , .. ( ) ,
my_instance.get_accumulated_interest(). , . - -
clean , clean . , . - , , , .
- , - .
" X", , , Django alltogether. .
Edit:
" " , . Q , :
q = Q(field__isnull = False) | Q(otherfield__isnull = False)
objects = Model.objects.filter(q)
II:
: Python . . :
def HasFooBar(model_class):
return list(model_class.objects.filter(somefield__contains = 'foobar'))
def BarHasBaz(model_class, arg):
return list(model_class.objects.filter(somefield = arg))
objects = HasFooBar(MyModel) + BarHasBaz(OtherModel, baz)
, ?:)