Home > Software design >  What's the difference between a top level module and a sub-module in Django when using - "
What's the difference between a top level module and a sub-module in Django when using - "

Time:10-12

I followed the polls tutorial for Django and am beginning my own hobby project today. When creating an app, the following really confused me -

Your apps can live anywhere on your Python path. In this tutorial, we’ll create our poll app in the same directory as your manage.py file so that it can be imported as its own top-level module, rather than a submodule of mysite.

So my question is - What is the difference between a top-level module vs a submodule for my project?

And how do I decide which one to choose?

Any help will be greatly appreciated as I am a noob coder working on my first hobby project lol.

CodePudding user response:

There's no real other difference than matters of taste, organization, and naming.

For what it's worth, with my 10 years of Django, I still generally like to just have the app packages parallel to the project package (i.e. what that passage suggests).

(It's occasionally also handy to make the project package an app, for some very core models such as custom users, etc.)

There are cases when it does make sense to have packages of interrelated apps, but those are generally for reusable apps such as allauth etc.

  • Related