项目结构是否正确?

问题描述 投票:0回答:1

这是我的项目的结构:

├─── applications
│ ├─── about
│ │ ├─── admin.py
│ │ ├─── api
│ │ │ │ └─── __init__.py
│ │ │ ├─── apps.py
│ │ ├──── __init__.py
│ │ ├─── libs
│ │ │ │ └─── __init__.py
│ │ │ ├─── migrations
│ │ │ │ └─── __init__.py
│ │ ├─── models.py
│ │ │ ├─── services
│ │ │ │ └─── __init__.py
│ │ ├─── templates
│ │ ├─── tests.py
│ │ │ └─── views.py
│ ├─── account
│ │ │ ├─── admin.py
│ │ ├─── api
│ │ │ │ └─── __init__.py
│ │ │ ├─── apps.py
│ │ ├──── __init__.py
│ │ ├─── libs
│ │ │ │ └─── __init__.py
│ │ │ ├─── migrations
│ │ │ │ └─── __init__.py
│ │ ├─── models.py
│ │ │ ├─── services
│ │ │ │ └─── __init__.py
│ │ ├─── templates
│ │ ├─── tests.py
│ │ │ └─── views.py
│ ├─── blog
│ │ │ ├─── admin.py
│ │ ├─── api
│ │ │ │ └─── __init__.py
│ │ │ ├─── apps.py
│ │ ├──── __init__.py
│ │ ├─── libs
│ │ │ │ └─── __init__.py
│ │ │ ├─── migrations
│ │ │ │ └─── __init__.py
│ │ ├─── models.py
│ │ │ ├─── services
│ │ │ │ └─── __init__.py
│ │ ├─── templates
│ │ ├─── tests.py
│ │ │ └─── views.py
│ ├─── middlware
│ ├─── order
│ │ ├─── admin.py
│ │ ├─── api
│ │ │ │ └─── __init__.py
│ │ │ ├─── apps.py
│ │ ├──── __init__.py
│ │ ├─── libs
│ │ │ │ └─── __init__.py
│ │ │ ├─── migrations
│ │ │ │ └─── __init__.py
│ │ ├─── models.py
│ │ │ ├─── services
│ │ │ │ └─── __init__.py
│ │ ├─── templates
│ │ ├─── tests.py
│ │ │ └─── views.py
│ └─── product
│ ├─── admin.py
│ ├─── api
│ │ │ └─── __init__.py
│ ├─── apps.py
│ ├─── __init__.py
│ ├─── libs
│ │ │ └─── __init__.py
│ ├─── migrations
│ │ │ └─── __init__.py
│ ├─── models.py
│ ├─── services
│ │ │ └─── __init__.py
│ ├─── templates
│ ├─── tests.py
│ └─── views.py
├─── configs
│ ├─── asgi.py
│ ├─── __init__.py
│ ├─── settings.py
│ ├├─── urls.py
│ └─── wsgi.py
└─── manage.py
configs - project settings
applications - apps:)
middleware - middleware:)
application/app/libs - python libraries (I think it's better to use the standard interface for python libraries and add them to site-packages, even if they are written by me)
application/app/api - third-party api (I think it's better to put the api on the top level)
application/app/templates - templates 
application/app/services + models.py - business logic
application/app/views.py - views

什么是更好的改变?这种结构对于普通团队来说“好”吗?

P.S 我还想知道如果订单使用帐户和产品中的模型(我想到在 AUTH_USER_MODEL 这样的设置中引用模型),应该如何处理 django 应用程序之间的交互。

我读过很多关于在 django 中构建 Web 应用程序的有效模式的文章,但我还没有找到最好的方法

python django web django-models architecture
1个回答
0
投票
project_name/
│
├── applications/
│   ├── about/
│   │   ├── admin.py
│   │   ├── apps.py
│   │   ├── __init__.py
│   │   ├── libs/               # Python libraries specific to this app
│   │   ├── middleware/         # Middleware specific to this app
│   │   ├── api/                # Third-party API specific to this app
│   │   ├── templates/          # Templates specific to this app
│   │   ├── services/           # Business logic specific to this app
│   │   │   └── models.py
│   │   └── views.py            # Views specific to this app
│   │
│   ├── account/
│   │   ├── admin.py
│   │   ├── apps.py
│   │   ├── __init__.py
│   │   ├── libs/
│   │   ├── middleware/
│   │   ├── api/
│   │   ├── templates/
│   │   ├── services/
│   │   │   └── models.py
│   │   └── views.py
│   │
│   ├── blog/
│   │   ├── admin.py
│   │   ├── apps.py
│   │   ├── __init__.py
│   │   ├── libs/
│   │   ├── middleware/
│   │   ├── api/
│   │   ├── templates/
│   │   ├── services/
│   │   │   └── models.py
│   │   └── views.py
│   │
│   ├── order/
│   │   ├── admin.py
│   │   ├── apps.py
│   │   ├── __init__.py
│   │   ├── libs/
│   │   ├── middleware/
│   │   ├── api/
│   │   ├── templates/
│   │   ├── services/
│   │   │   └── models.py
│   │   └── views.py
│   │
│   └── product/
│       ├── admin.py
│       ├── apps.py
│       ├── __init__.py
│       ├── libs/
│       ├── middleware/
│       ├── api/
│       ├── templates/
│       ├── services/
│       │   └── models.py
│       └── views.py
│
├── configs/
│   ├── asgi.py
│   ├── __init__.py
│   ├── settings.py
│   ├── urls.py
│   └── wsgi.py
│
└── manage.py
© www.soinside.com 2019 - 2024. All rights reserved.