or maybe the app has to be more focused, and split in two or more apps.
> 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 module that works on your models and is
managed by the views in similar ways to them.
but in the end, yes: the vast majority of business logic belongs in
models.py files, definitely not in the views.
--
Javier
/models/
/models/__init__.py
/models/invoices.py
/models/products.py
/models/taxes.py
...
The are two tricks to the above to make it work however; first you must
import your files in the __init__.py and manually specify the app_label for
all your model files:
# /models__init__.py
from .taxes import *
from .products import *
from .sandh_costs import *
from .discounts import
# /models/taxes.py
class DiscountBase(models.Model):
...
### model options - "anything that's not a field"
class Meta:
app_label = 'pnpstore' # must specify same app label so that in
admin models are grouped correctly
I also split views in a similar manner.
--
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...@googlegroups.com.
To unsubscribe from this group, send email to
django-users...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
Daniel Sokolowski
Web Engineer
KL Insight
http://klinsight.com/
Tel: 613-344-2116 | Fax: 613.634.7029
993 Princess Street, Suite 212
Kingston, ON K7L 1H3, Canada