Structuring large/complex Django projects, and using a services layer in Django projects

Hi Kye,

Welcome to the forum. And what a post to start it off!

  • is there any publicly available (paid is ok) literature or training available that covers how to best structure a large, ongoing, mature Django project?

Here’s a quick saturday braindump…

Octopus Energy have a few posts on their ideas of structure, plus their own style guide, see their tech blog: https://tech.octopus.energy/

This is probably the Tom Christie post you were thinking of: Django models and encapsulation - DabApps

This recent forum discussion covers many’s approaches to apps and structure: Why do we need apps?

Dan Palmer at Thread on their 350 django app structure: Scaling Django Codebases at PyCon UK 2017 – Dan Palmer

This book from Harry Percival and Bob Gregory that is in “beta” and can be read for free seems promising, quite a few people mentioned it to me/on Twitter in the last couple weeks: https://www.cosmicpython.com/ . It covers more general Python application design, from their starting point of wanting to make things testable.

  • Does anyone have any experience writing complex Django applications with a services layer as discussed in the linked style guide ? How has it gone for you? Has it saved more time than it’s spent having to override or reimplement Django’s provided batteries?

Where I worked at YPlan we had some “services” layers but they weren’t enforced as the only architectural pattern.

I think you’ve hit the nail on the head that it can be a lot of time reimplementing “batteries”. Django’s forms and models layers are a bit more intertwined than I’d like, but this is a time-saving measure when getting things off the ground. Likewise with many other shortcuts that Django offers, they can come back to bite you when there’s a lot of code going through them.

I’m not sure there’s a general purpose answer out there at the moment. I’m not sure many of the larger Django projects feel like they’re “there” either.

11 Likes