Django Folder Structure - herougo/SoftwareEngineerKnowledgeRepository GitHub Wiki

Simple TechWithTim Example (Not Preferred)

https://github.com/techwithtim/Music-Controller-Web-App-Tutorial/

  • music_controller
    • wsgi.py
  • spotify
  • frontend
  • api

HackSoftware (Not Preferred?)

https://github.com/HackSoftware/Django-Styleguide-Example/

  • config
    • wsgi.py
  • styleguide_example
    • (apps)
  • manage.py
  • ...

James Beith (More Preferred)

https://www.jamesbeith.co.uk/blog/how-to-structure-django-projects/

  • src/
    • crema/
      • data/
        • migrations/
        • models/
      • domain/
        • baskets/
        • orders/
        • products/
        • users/
      • interfaces/
        • actions/
          • management/
            • commands/
        • dashboard/
          • orders/
          • products/
          • users/
        • store/
          • account/
          • basket/
          • checkout/
          • products/
    • tests/
      • functional/
      • unit/

Reddit Ideas

Link 1

https://www.reddit.com/r/django/comments/ryyxtk/the_best_structure_for_a_django_project_in_your/

All Models in One App, Other Apps Added (Less Preferred)

  • all models and admin in one app (ex: core app)
  • views and serializers are separated in their respective apps

Many Apps with Models in Each App (Less Preferred)

  • every time I create a new app I write my models inside of it

Pros

  1. Sometimes an app will have generalized purpose and I decide to separate it out into its own standalone app and pip package, so I can reuse it in other projects.

  2. It is much easier when a project evolves to the point that you need to implement micro services architecture by separating the project into multiple smaller standalone projects that can communicate with each other.

philgyford (Less Preferred)

  • core
  • api
  • bookmarks
  • comments
  • photos
  • weblog
  • users

Link 2

https://www.reddit.com/r/django/comments/sg1gbc/whats_your_most_clean_project_folder_structure/

patryk-tech (Less Preferred?)

foo  # or foo-bar
├── foo  # or foo_bar
│  ├── asgi.py
│  ├── __init__.py
│  ├── settings.py
│  ├── urls.py
│  ├── users  # repeat for as many apps as you want
│  │  ├── admin.py
│  │  ├── apps.py
│  │  ├── __init__.py
│  │  ├── migrations
│  │  │  └── __init__.py
│  │  ├── models.py
│  │  └── views.py
│  └── wsgi.py
├── manage.py
└── tests
    └── users.py  # repeat for as many apps. Sometimes I nest each app in a tests subdir.

Link 3

https://www.reddit.com/r/django/comments/180jisv/how_to_structure_project_using_apps/

Ideas:

  • split apps by public-facing and private