bruno.42.desthuilliers at websiteburo.invalid
Tue Mar 3 16:09:18 CET 2009
koranthala a écrit :
> Hi Bruno,
> After reading your email, I tried reworking my code so that most of
> my logic moves to Models.
> But, most probably because this is my first application
> development, I am unable to do so.
> For example:
> I have Models A,B, C, D . Now, there is not much model specific
> code (preprocessing before updating code inside Models)in it. Rather
> most of the code is of the format:
> data received and to be added to D. But for adding to D, check
> whether it is already in C - if not add to C and B. etc...
And you don't find it "model specific" ? Man, this is business rules,
and as such belongs to the models part, not to views. You surely want to
make sure these rules always apply, don't you ?
> Now, I tried putting this code inside Model D,but it does not seem
> to belong there - since it modifies other Models.
And ? Who said a Model (or ModelManager) shouldn't touch other models ?
> Is keeping such code inside views against Django's/Application-
> Developments philosophy?
FWIW, I see this antipattern (AnemicDomainModel) way too often in django
apps. This doesn't make it less of an antipattern.
> In that case, where will this go?
It's impossible to say exactly where in the models module without a
sufficiant knowledge of the domain, rules etc. Sorry, but my crystal
ball is out for repair.
More information about the Python-list