Django project architecture
Asked Answered
D

3

7

As my Django projects are bigger and bigger I am facing issues regarding architecture. Before starting to code, I spend a lot of time to find a nice architecture for my project: how I split my project in apps, which apps are dependent on other apps and so on. To be clear, by architecture I don't mean project layout.

I have done my research and I haven't found yet a ressource showcasing some methods to find the best architecture for a given Django project. Outside web development, UML seems to be the way to go.

My questions are:

1) Why is there almost no discussion about those topics on the internet ? Am I missing something and totally wrong in my approach ?

2) Can UML be used to work on Django project architecture ?

3) Is there a common way to tackle this issue with Django ?

Dierdre answered 25/9, 2016 at 12:14 Comment(0)
M
6

Before starting to code, I spend a lot of time to find a nice architecture for my project: how I split my project in apps, which apps are dependent on other apps and so on.

I think you're overthinking this. Your project architecture can (& probably should) evolve as you go. You can start with 1 big app and then split it when the appropriate structure becomes obvious to you.

1) Why is there almost no discussion about those topics on the internet ? Am I missing something and totally wrong in my approach ?

Because the short answer is "it's up to you" or "it depends on your project". This will help you: Django: best practice for splitting up project into apps

2) Can UML be used to work on Django project architecture ?

I don't see why not.

3) Is there a common way to tackle this issue with Django ?

There are several ways, consider dividing your apps around:

  • Responsabilities (1 app to do 1 thing)
  • Reusability (an app could be ported with no to limited changes to another project)
  • Ease of use (another dev can guess where a model / view should be)
Milled answered 25/9, 2016 at 12:29 Comment(3)
I dont think that making an architecture before coding is overdoing in any way. This is the best approach one can take. Think first, act afterwards. Not vice versa.Mousetrap
Previously I used to go straight to the code but I noticed that I am much more productive when I plan ahead. When design is well done, coding becomes much more easierDierdre
I'm not saying to go straight into code but there is a balance to find, basically: think a little => act => reiterate.Clara
L
2

If you would like to have some guidance on how to create a UML design for a web application, you may like my white paper "Technical design in UML for AngularJS applications". It focuses on Angular apps, but most of it applies to web apps in general.

Lody answered 25/9, 2016 at 18:39 Comment(1)
Thanks I will have a look at it!Dierdre
D
1

After gathering more information I came accross an interesting architecture (I have found the idea on reddit but could not retrieve the url).

Your whole code should be sperated into independent apps (separation of concern) and you need to define 2 "project wide" apps (site and utils):

  • the site app can depend on any other app.
  • the utils app does not depend on other apps but other apps can depend on it.
  • the independent apps can only depend on utils.
Dierdre answered 4/10, 2016 at 10:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.