如何管理同一项目的不同客户的不同存储库?

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

早上好,我必须管理一个 Django 项目,其中每个客户端在应用程序和 API 端点方面都有小的定制。我希望避免为每个客户管理太多分支机构:

第一个解决方案

在 .env 文件中,添加一个指示客户端的字段

CUSTOMER=customer1

#settings.py
#...
INSTALLED_APPS = [
    "django.contrib.admin",
    "django.contrib.auth",
    "django.contrib.contenttypes",
    "django.contrib.sessions",
    "django.contrib.messages",
    "django.contrib.staticfiles",
    "rest_framework",
    "rest_framework_simplejwt",

]

customer = os.getenv("CUSTOMER")

if customer == "customer1":
    INSTALLED_APPS.append('custom_customer1')

第二个解决方案

根据客户端使用各种分支,各种合并来自 master/main

开发 --> master --> customer1_develop --> customer1_master

您推荐哪种系统?

django git architecture
1个回答
0
投票

一个想法可能是存储要添加到

INSTALLED_APPS
CUSTOMER
环境变量的应用程序列表:

# settings.py

import ast

# …

customer = os.getenv('CUSTOMER', '[]')

INSTALLED_APPS += ast.literal_eval(customer)

然后我们将

['custom_customer1']
存储在
CUSTOMER
环境变量中。

© www.soinside.com 2019 - 2024. All rights reserved.