TechPertz
TechPertz

Reputation: 16

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

Now, I have gone through the Django tenant approach which uses PostgreSQL. But I am looking for something in 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?

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.

Upvotes: 0

Views: 247

Answers (1)

itsmehemant7
itsmehemant7

Reputation: 343

I think there are 2 ways (according to me) of doing it.

  1. You can use proxy API to make the process easy. You have to keep and maintain only one DB. Just use different URLs for different subdomains.

  2. This is my personal method which I am currently using. I use Pythonanywhere for deploying my applications. 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.

Upvotes: 1

Related Questions