Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 76817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:43:58+00:00 2026-05-10T20:43:58+00:00

What options are there for installing Django such that multiple users (each with an

  • 0

What options are there for installing Django such that multiple users (each with an ‘Account’) can each have their own database?

The semantics are fairly intuitive. There may be more than one User for an Account. An Account has a unique database (and a database corresponds to an account). Picture WordPressMU. 🙂

I’ve considered this:

  1. External solution – Multiplex to multiple servers/daemons

    Multiple Django installations, with each Django installation / project corresponding to an account that sets its own DATABASE_NAME, e.g.

    File system:

    /bob   /settings.py (contains DATABASE_NAME='bob')  /sue   /settings.py (contains DATABASE_NAME='sue') 

    Then having a Django instance running for each of bob and sue. I don’t like this methodology- it feels brutish and it smells foul. But I’m confident it would work, and based on the suggestions it might be the cleanest, smartest way to do it.

    The apps can be stored elsewhere; the only thing that need be unique to the django configuration is the settings.py (and even there, only DATABASE_NAME, etc. need be different, the rest can be imported).

    (Incidentally, I’m using lighttpd and FastCGI.)

  2. Internal solution – Django multiplexing database settings

    On the other hand, I’ve thought of having one single Django installation, and

    (a) Adding a ‘prefix_’ to each database table, corresponding to account of the logged-in user; or

    (b) Changing the database according to the account of the User that is logged in.

    I’d be particularly interested in seeing the ‘Django way’ to do these (hoping that it’s something dead-simple). For example, middleware that takes a Request’s User and changes the django.conf.SETTINGS[‘DATABASE_NAME’] to the database for this user’s account.

    This raises red flags, viz. Is this thread-safe? i.e. Does changing django.conf.SETTINGS affect other processes? Is there just an inherent danger in changing django.conf.SETTINGS — would the DB connection be setup already? Is restarting the DB connection part of the public API? — I’m going to have a look at the Django source when I look to this problem again.

    I’m conscious that 2(a) and (b) could require User authentication to be stored and accessed in a different mechanism that the core.

For now, I’m going to go with the external mapping at the webserver layer- it’s simplest and cleanest for now. However, I don’t like the idea of FastCGI daemons running for every account- it seems to needlessly waste memory, particularly if there will be 2000+ accounts. However, I’d like to keep this discussion open as it’s an interesting problem and the solution doesn’t seem ideal for certain cases.

Comments duly appreciated. Cheers

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T20:43:59+00:00Added an answer on May 10, 2026 at 8:43 pm

    The Django way would definitely be to have separate installations with their own database name (#1). #2 would involve quite a bit of hacking with the ORM, and even then I’m not quite sure it’s possible at all.

    But mind you, you don’t need a WHOLE new installation of all the site’s models/views/templates for each user, just a new settings.py with all the appropriate paths to the common source files. Plus, to run all these installations in Apache, do it the way I do here:

    <VirtualHost 1.2.3.4>         DocumentRoot /www/site1         ServerName site1.com         <Location />                 SetHandler python-program                 SetEnv DJANGO_SETTINGS_MODULE site1.settings                 PythonPath '['/www'] + sys.path'                 PythonDebug On                 PythonInterpreter site1         </Location> </VirtualHost>  <VirtualHost 1.2.3.4>         DocumentRoot /www/site2         ServerName site2.com         <Location />                 SetHandler python-program                 SetEnv DJANGO_SETTINGS_MODULE site2.settings                 PythonPath '['/www'] + sys.path'                 PythonDebug On                 PythonInterpreter site2         </Location> </VirtualHost> 

    assuming you’ve got /www/site1/settings.py, www/site2/settings.py and so on…

    Of course, you now need to have a main site where people log in, that then redirects you to the appropriate site (here I’ve just put it as ‘site1.com’, ‘site2.com’, but you get the idea.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 118k
  • Answers 118k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I'm not quite sure if your question implies that all… May 11, 2026 at 11:33 pm
  • Editorial Team
    Editorial Team added an answer Start by removing -I/usr/include/linux and -I/usr/include. Adding system directories to… May 11, 2026 at 11:33 pm
  • Editorial Team
    Editorial Team added an answer You can very seldom use output redirection to replace the… May 11, 2026 at 11:33 pm

Related Questions

Most projects have some sort of data that are essentially static between releases and
Our win32 applications (written in C++) have been around for over 10 years, and
Say you have an app, that you want to provide users ability to browse
XAMPP makes configuring a local LAMP stack for windows a breeze. So it's quite

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.