On Apr 23, 3:45 pm, Javier Guerra Giraldez <jav...@guerrag.com> wrote:
> On Mon, Apr 23, 2012 at 6:47 AM, bruno desthuilliers
>
> <bruno.desthuilli...@gmail.com> wrote:
> > Models - like any other module - should indeed be "as simple as
> > possible", _but not simpler_. If you concern is about your models.py
> > file size, it might be time to refactor it into a package.
>
> or maybe the app has to be more focused, and split in two or more apps.
Possibly, but sometimes the complexity is inherent to the domain and
trying to split the app just makes things more complicated for no good
reason.
> > Now if there are parts of your methods that are low-level enough and
> > don't really need to know about your models, yeps, they may belong to
> > some "model-agnostic" utility module.
>
> also when the usercase concepts are not exactly the same as the
> database records. then another model-like layer can be useful.
>
> for example, lets say you're working with a genealogy application, and
> you have a Person model, and several kinds of relationships between
> person instances. But let's also say that you have a 'Family'
> concept that is easy to derive from the database (so it doesn't need
> another model class), but you want to add some extra behaviour at the
> Family level (above Person and Relationship). then it might be
> useful to add a new Family.py
please make it lowercase ;)
> module that works on your models
"model" is kind of an overloaded term here - there's the Django
"Model" class, and there's the "domain model" layer. As far as I'm
concerned, it all belongs to the "models" module / package, even if
there's not a single "Model" class involved.
> but in the end, yes: the vast majority of business logic belongs in
> models.py files, definitely not in the views.
Indeed.
> --
> Javier
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment