canonical-django team mailing list archive
-
canonical-django team
-
Mailing list archive
-
Message #00028
Re: Django testing best practices
On Mon, Jun 14, 2010 at 4:35 AM, Nick Moffitt <nick@xxxxxxxxxxxxx> wrote:
> James Westby:
>> As we add more behaviour to models we will be testing that, and it was
>> agreed that this was where most of the logic should be pushed too, so
>> views are as simple as possible.
>
> I have this feeling that models ought to have more methods than we
> typically give them. Often when we refactor some complicated query
> logic out of a view function, we leave it in our views.py; but perhaps
> we ought to be moving more testable representation logic into our
> models.
>
> This specifically is something that has little in the way of good
> concrete examples out in the wild. None of the tutorials for Django put
> much of anything beyond fields and __unicode__() in the models, for
> example.
>
I've found it's quite common among Django devs to stick a lot of logic
in the model and reserve view functions for object retrieval and form
handling only. This was common practice when I worked in the news
industry on large Django-based apps. I'm not sure how well this is
represented in open source Django apps since these tend to be very
small apps where only the basic methods are implemented.
Cheers,
deryck
--
Deryck Hodge
https://launchpad.net/~deryck
http://www.devurandom.org/
References