On Thu, Feb 13, 2020 at 6:34 PM Mrunalini Ramnath <[email protected]> wrote:
> Hey folks! > I've been researching on effective ways to separate business logic from > views.py. I currently also have separate files for helper functions but the > codebase is still a little cluttered. > How about going on the traditional MVC way? Your views act as controllers with only one concern i.e. to operate on the HTTP plane, call services, raise exceptions maybe. I generally create a *service.py* in each app to implement the business logic and just call it inside my *views.py*. It helps to make my business logic loosely coupled with the web-server. Also, it has an upside that it makes testing easier. > I found this method of implementation that involves creating a manager > class for each model that can contain all the necessary functions, and thin > views for executing said function. There are quite a few sources pertaining > to this but I found this to be the strongest one in support so far: > https://sunscrapers.com/blog/where-to-put-business-logic-django/#Idea_4_QuerySetsManagers > > Are there any more pros and cons that haven't been discussed in it? > > -- > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/a893a097-c091-42ae-9638-ec4cf0ec8a9d%40googlegroups.com > <https://groups.google.com/d/msgid/django-users/a893a097-c091-42ae-9638-ec4cf0ec8a9d%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAD%3DM5eTWKRMcszkWA3EEEUbauQ7n3qKoB1VBrDc9BJ4uj9a%2BYQ%40mail.gmail.com.

