How to create SaaS application with Python and Django

寵の児 提交于 2019-12-20 07:58:19

问题


Can you advice me with some articles/applications that allows you create SaaS(Software as a Service) application with Python and Django.

For the moment the general topics I do not understand are:

  1. Do you have one working application for all clients or one app per client
  2. How do you manage database access, permissions or different DB for each client
  3. Are there any tools that allows you to convert one app to SaaS

回答1:


  1. one project, this will make maintenance easier. I handle host resolution with middleware in django-ikari.
  2. you don't. see #1
  3. I use the following :

    • django-ikari : anchored (sub)domains
    • django-guardian : per object permissions
    • django-tastypie : easy RESTful api
    • django-userprofiles : better than django-registration
    • django-billing : plan based subscription controls
    • django-pricing : plan based subscription definition
  4. While not necessary, the following will help in the long run:

    • django-hunger : private beta signups
    • django-waffle : feature flip
    • django-classy-tags : nice, easy and neat templatetag creation
    • django-merchant : abstracted payment gateway framework
    • django-mockups : fast testing with models
    • django-merlin : better multi-step forms (wizards)
  5. Finally, nice to have

    • django-activity-stream



回答2:


A very basic, elementary example of how you would go about it.

Suppose you have a simple app designed to solve a particular business case. For example, you created an app to handle room reservations at your office.

To "convert" this app into a service you have to configure it such that most of the user-specific parts of the application are parametric (they can be "templatized" - for lack of better word).

This is how the front end would be converted. You might create variables to hold the logo, headline, teaser, color scheme for the app; allowing each user to customize their instance.

So far, your app is able to customize itself on the front end. It is still using the same database that was designed in phase one.

Now comes the matter of showing only those fields that are relevant to a particular user. This would be parameterizing the database. So you might add a column that identifies each row as belonging to a particular user; then create views or stored procedures that filter records based on the logged in user.

Now the application is able to be "rented" out; since you are able to customize the instance based on the user.

It then just gets bigger from here - depending on the scale, type and intended customization of your application. You might decide that your application performs better when each user has their own dedicated database instead of the stored procedure + view combo.

You may decide that for some user types (or "packages"), you need a dedicated instance of your application running. So for "premium" or "ultra" users you want to have their own dedicated system running.

If your application requires lots of storage - you might decide to charge separately for storage.

The bottom line is it has nothing to do with the language used. Its more an architecture and design problem.




回答3:


Software as a Service is just a marketing word, it's technically no different from a server that is accessible over the internet. So question 3 makes no sense. That leaves us with question 1 and 2:

  1. What do you mean with 'app' in this context? Your web application (built with Python and Django) can have multiple Django apps (components that make up the web application) but I think that's not what you mean. You can build your website in Python/Django and have various customization options depending on which user (client) is logged in. For example, a premium client can have several advanced options enabled but it's still part of the same codebase. It's just that some options (buttons/controls, etc) are not shown for certain clients

  2. Django has plenty of tools for user management, permissions and groups. You can give each user (each client) different permissions and these permissions determine what they can do. Database access should be managed by your web application. For example, the code determines what information needs to be displayed on the webpage (depending on which client is logged in) and that code retrieves the information from the database. Depending on the scale that you're aiming for, you can also specify which database should be used to retrieve the information from.




回答4:


I have a blog post describing my proposal of how to go about making a multi tenant SAAS web application using Django. Multi-tenancy here means that when user registers, they have their sub-domain. To recap:

  • All tenants share one database, but each has their own schemas. Imagine you have website abc.com and someone registered a xyz tenant so that they access their page through xyz.abc.com, then for a tenant xyz you have a separate schema containing all the tables thus encapsulating data related only to xyz tenant. There are other ways, like having one database and one schema for all, or having even separate databases. But schemas approach is the best trade-off. The django-tenants library's documentation contains more detailed info if you are interested
  • Use django-tenants library to abstract away work with tenants. When someone accesses xyz.abc.com, you need to know that xyz is the tenant and that you should use xyz schema. django-tenants library does this for you so on each request you can obtain the tenant object by simply doing current_tenant = request.tenant
  • You need to differentiate between shared tables and tenant-specific tables. For example, having table with list of orders is tenant-specific. Every tenant might have their own database containing all their orders. This table should be inside xyz schema. At the same time, you will have some core Django tables, like user. The data can be shared, for example, to disallow two users registering with the same email.
  • You need to configure your DNS to catch a wildcard expression *.abc.com, for which you can add an A record inside your CPanel with *.abc.com linking to the IP of your server


来源:https://stackoverflow.com/questions/9924169/how-to-create-saas-application-with-python-and-django

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!