Creating a customer database within a user database

Good afternoon,

I’m trying to figure out what the best practice is for using Django. I have a website that uses Django and the sqlite3 database. I would then be using an external database on deployment. My site would have subscribers, and within each profile for those subscribers, they would have the ability to create a database/portfolio of customers and projects. Would the customer and project databases for each user be included in the sqlit3/external database? Or would I just use csv files or some other form of organization? I’m fairly new to this, so any direction would be appreciated.

Also if you could give me some direction oh creating that project/customer database within the Django code, that would held. I have a Flask file that outputs a csv file from a form, but I’m not sure how to convert it into Django.

Thanks!

Welcome @mprovost129 !

What you should actually be looking to do is to allow each subscriber to have data in your database that is reserved for them alone, perhaps identified by something like a “subscriber_id” value.

Django does not facilitate creating databases on the fly. Plan on storing all the data in your database, ensuring that you restrict access to the data for the appropriate users.

If you are willing to move to PostgreSQL, you could take a look at django-tenants which does something similar. Keep in mind that this kind of approach may not scale up very well (you may end up with a lot of DB schemas on PostgreSQL which will slow down your migration process).

Here is a nice blog post which talks about multi-tenancy with django (using django-tenants): Building a Multi-tenant App with Django | TestDriven.io