When to create a new app (with startapp) in Django?

前端 未结 8 1998
余生分开走
余生分开走 2020-12-12 15:44

I\'ve googled around for this, but I still have trouble relating to what Django defines as \"apps\".

Should I create a new app for each piece of functionality in a

相关标签:
8条回答
  • The two best answers to this question I've found around the web are:

    1. The Reusable Apps Talk (slides)(video) also mentioned in other answers. Bennett, the author and Django contributor, regularly publishes apps for others to use and has a strong viewpoint towards many small apps.
    2. Doordash's Tips for Django at Scale which gives the opposite advice and says in their case they migrated to one single app after starting with many separate apps. They ran into problems with the migration dependency graph between apps.

    Both sources agree that you should create a separate app in the following situations:

    • If you plan to reuse your app in another Django project (especially if you plan to publish it for others to reuse).
    • If the app has few or no dependencies between it and another app. Here you might be able to imagine an app running as its own microservice in the future.
    0 讨论(0)
  • 2020-12-12 16:49

    James Bennett has a wonderful set of slides on how to organize reusable apps in Django.

    0 讨论(0)
提交回复
热议问题