简体   繁体   English

使用 mysql 在单个 django 项目中设置多个子域的最佳方法是什么?

[英]What will be the best approach for setting up multiple subdomains in a single django project using mysql?

I am about to build a web-app and use it as a product for multiple organizations.我即将构建一个网络应用程序并将其用作多个组织的产品。

Let's say my domain name is example.com And I have 2 customers, org1 (Organization 1) and org2 (Organization 2) So, my sub domains would be org1.example.com and org2.example.com假设我的域名是 example.com 我有 2 个客户,org1(组织 1)和 org2(组织 2)所以,我的子域是 org1.example.com 和 org2.example.com

Now, I have gone through the Django tenant approach which uses PostgreSQL. But I am looking for something in MySQL.现在,我已经完成了使用 PostgreSQL 的 Django 租户方法。但我正在寻找 MySQL 中的内容。

But my question is that is it possible for me to use MySQL and use separate databases, to maintain risk free and also data privacy for orgs, and also use Django tenant or is there some different approach to solve this subdomain issue?但我的问题是,我是否可以使用 MySQL 并使用单独的数据库,以保持组织的无风险和数据隐私,并使用 Django 租户,或者是否有一些不同的方法来解决这个子域问题?

Do note, I'll be using my platform as a product so the subdomains would be given to each client who would be given credentials to access the platform (Kinda like an inventory system).请注意,我将使用我的平台作为产品,因此子域将提供给每个客户,他们将获得访问平台的凭据(有点像库存系统)。 Any links or videos is highly appreciated.非常感谢任何链接或视频。

I think there are 2 ways (according to me) of doing it.我认为有两种方法(根据我的说法)可以做到这一点。

  1. You can use proxy API to make the process easy.您可以使用代理 API 来简化此过程。 You have to keep and maintain only one DB.您只需保留和维护一个数据库。 Just use different URLs for different subdomains.只需为不同的子域使用不同的 URL。

  2. This is my personal method which I am currently using.这是我目前正在使用的个人方法。 I use Pythonanywhere for deploying my applications.我使用Pythonanywhere来部署我的应用程序。 This is the most convenient platform I have ever seen for the web. Just map your domains/subdomains to the same project directory and you can use the same Mysql database for all websites without any issue.对于 web,这是我见过的最方便的平台。只要 map 将您的域/子域添加到同一项目目录,您就可以对所有网站使用相同的 Mysql 数据库,没有任何问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM