Whenever I do the same query in a couple of different views, I try to pull it out into a manager method[1]. For instance, get all the stories that are marked published from the last two days. I would make this a method on the manager so I can reuse it other places. Then I write a test for that manager method to make sure it was selecting the right stuff. (Not a mutating operation, but it is model-related)
Hope that helps, Alex [1] http://docs.djangoproject.com/en/dev/topics/db/managers/#topics-db-managers On Jul 16, 4:27 am, Joshua Russo <josh.r.ru...@gmail.com> wrote: > > 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. > > I find this really interesting because I wanted to put more code into > the models but couldn't seem to find the right hooks to accomplish my > specific tasks. > > What are some examples of mutating operations (and other operations > for that matter) that you use in your models? > > Thanks for your suggestions > Josh --~--~---------~--~----~------------~-------~--~----~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---