I'm really struggling with this whole app-idea. I read a lot of tutorials and style guides and I know I should try to create specialized apps, that do exactly one thing. This all makes sense when looking at some simple tutorial project but as soon as it gets to a complex real life project, I find myself unable to determine how I should draw the lines between different apps.
One of the problems is, that I want to have one site (or multiple sites) where the user sees a lot of different stuff. Stuff that should be from different apps, when following the app design rules. How would I realize something like this? My first idea was to create one app called ui
, that just handles ALL the views the actually lead to a template and all the other apps provide the models and helperfunctions. But I fear that the ui
app will become way to big.
To give you a small example: Lets I want to have a site where the user can do the following tasks:
Right now, I would create three apps:
But then, I would need some kind of main
or ui
app to handle how these apps interact and to create the actual site, where all the apps are somehow involved.
So, is there any "right" way to do this? Or are there any patterns that I can use? I would also appreciate links to good resources about this topic, even though I already read quite a few.
You just need to make sure your structure makes sense to you.
There's no requirement to create a new app for every feature that is bound to another part of the project's logic.
Reusable apps are a whole different story, their code should be unaware of the implementation to some extent.
Take a look at Django's structure for inspiration
A possible layout for your example:
project_root/
project/
__init__.py
settings.py
urls.py
templates/
app1/ # override stuff
static/
media/
app1/
__init__.py
admin/ # as a package
__init__.py
subjects.py
resources.py
# etc
models/ # as a package
subjects.py
resources.py
# etc
managers/
__init__.py
subjects.py
resources.py
# etc
services/
__init__.py
audio.py # upload handler etc
views/
__init__.py
subjects.py
urls/
__init__.py
subjects.py
templates/
app1/
subject_list.html # override at project level
static/
app1/
css/
subject.css # override at project level
app2/
__init__.py
models.py # holds a Member model or whatever you require
manage.py