Django. One app with many models vs. many apps with single model

后端 未结 5 1802
眼角桃花
眼角桃花 2020-12-08 00:42

I\'m currently developing my own weblog in Django. But I\'ve already stucked right in the beginning. So, here is my tree hierarchy:

/pyroot/nemo         


        
5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-08 01:10

    My subjective view is that apps are meant to be reusable. If they are truly reusable you could pip install on your next project. So basically reusable apps should be separate from your codebase and ideally on pypi.

    I just use one app per project and use packages to break up modules.

    eg.

    Before

    journal/
      models.py
    

    After

    journal/
       models/  # All models share the same database namespace. In this case 'journal_'
          __init__.py
          auth.py
          page.py
    

提交回复
热议问题