Yep, I'm more or less convinced that the logic needed for sending an email should go into models. But what about the action (method call) of sending the email? what layer should be responsible for triggering an email notification? models or views? This is something I keep wondering myself for a long time ...
for example, imagine we have a simple Ticket model with two methods, update() and notify_owner() class Ticket(models.Model): def update(self): self.updated_on = now() self.save() def notify_owner(self, msg): send_mail(self.owner, msg) now we want to notify the owner each time a Ticket is updated, shall we include a self.notify_owner('updated!') call on the update() method, so we make sure of that? or maybe it is better to do this on the view each time ticket.update() is called? There are some pros and cons, In the views we have access to the request object which some times is handy because we need some request info to include on the mail. Including the call into the model we make sure that each time we will send an email notification and DRY is good, but is this behavior correct? maybe we only want to notify under certain circumstances... So anyone has thought about this? any rule of thumb? maybe it totally depends on the use case? does this question even make sense? :) Thanks for your answers! -- Marc -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. For more options, visit https://groups.google.com/groups/opt_out.