Joshua Russo wrote: > This thought struck me most when I was going through the testing > documentation, in the section regarding the testing of models. It > seems to me that very little logic generally goes into the model > classes. At least for me, I have far more logic in admin.py and > views.py.
besides the testing issues (which are certainly a heated debate!), i have to say that my Django projects became far better organized and a lot more flexible when i learned to put most of the code on the models, and not on the views. IOW, it has become a lot more productive for me not to think in terms of the webapp, but in terms of the data objects. first invest a good portion of time (and several diagrams) getting the right structures to represent your data, add several methods to do any needed manipulation right in terms of the data, not in terms of the user's actions. sometimes it's necessary to add manager objects to make model objects more 'high-level' and not as tied to the RDBMS tables used to store them. with that structures in place, the view functions become very thin, just to get the needed objects for the templates, and interpret the user's actions to call any mutating operation on the relevant models. when you do that, it becomes clear that a lot of the tests can be right in the models.py file, to exercise said functionality. the tests.py is (mostly) reserved for testing the user interface, calling the URLs and verifying the response and effects. hope that helps, -- Javier --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---

