Decoupling Your Business Logic from the Django ORM

Where should I keep my business logic? This is a perennial topic in Django. We can imagine a continuum of cases, with increasing complexity: I begin with my...

The Stack Report
@carlton I thought this was a nicely nuanced and thoughtful article before even seeing the first attrs class, let alone cattrs ;)
@carlton disregarding specific libraries, there's definitely a rich discussion to be had around application architecture and complexity management here, and I think your entry here adds to it thoughtfully. I personally fall into the camp where I'll happily put the business logic meat into the "view", eschewing a service layer until the codepath needs to be shared. I have folks at $DAYJOB arguing otherwise, and not without merit.

@tintvrtkovic Ooh, good. Spicy 🌶️

I have OPINIONS about keep views bare... so I tend to have logic live in forms[*] — but people hate that too 😜

Glad you liked it. That you liked it before the cattrs reveal is extra nice, but you know I've been using it. (We can finally carry on our conversation: will you be in Bologna?)

[*]: It sounds crazy but is remarkably clean, I promise.

@carlton baby is still too demanding for conferences I'm afraid. Will have to wait until next year. Hynek is also pressuring me to get back out there 😇
@tintvrtkovic Take your time! The child grows too quickly. Meanwhile the conferences aren't going anywhere.

@carlton the argument goes that refactoring into a more abstract service layer on-demand runs into the risk of it being done inexpertly and inconsistently. Which I understand.

I guess, like many things in software engineering, the right call here depends on the people involved and not the technical arguments one way or another

@tintvrtkovic @carlton you’re going to hell for your singleton dependency module anyway so why not lean into it
@hynek @carlton that was a job ago. I wish I had that here
@carlton ohh what a timing! I’m giving my design pressure talk next week in Texas so it’s great to finally have some design content for Djagno, too!
@hynek I ❤️ that talk 🥳

@carlton The circle closes! ❤️

I really like to think that that talk put some thoughts and things in motion.