Reputation: 4149
Each site should have its own domain, database, settings.py, urls.py, views.py and so on. As far as I understand, it's impossible, but I don't quite sure.
EDIT: jdi suggests to use different settings files with different apps. Can you explain, please, how to do it? Additional problem is that I use Webfaction and after selecting existing Django webapp receive following error:
Site app with this Site, Path and Account already exists
So I need to know, is it limitation of Django or Webfaction. Version of Django is 1.3
Upvotes: 0
Views: 108
Reputation: 92647
This project structure is for Django 1.4, though the concepts remain the same
You can do all of that, just not with a single process. Create a single virtualenv for your project, which can store a shared set of every lib you need. Then create different settings files for each site, which each load different django apps, all located within the project:
djangoProject
|- bin/
|- include/
|- lib/
|- manage.py
|- djangoProject/
|- settings_site1.py
|- settings_site2.py
|- settings_site3.py
|- wsgi_site1.py
|- wsgi_site2.py
|- wsgi_site3.py
|- site1_app/
|- models.py
|- views.py
|- urls.py
|- site2_app/
|- models.py
|- views.py
|- urls.py
|- site3_app/
|- models.py
|- views.py
|- urls.py
settings_site1.py (example)
...
# or you could make multiple urls_siteX.py files in the root
ROOT_URLCONF = 'djangoProject.site1_app.urls'
...
INSTALLED_APPS = (
...
'djangoProject.site1_app'
)
wsgi_site1.py (example)
...
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "djangoProject.settings_site")
...
But to be perfectly honest... all of this is even much more easily accomplished if you just create a single virtualenv with multiple django projects. Then you don't have to much with segregating your apps:
projectEnv
|- bin/
|- include/
|- lib/
|- project1/
|- manage.py
|- project1/
|- project2/
|- manage.py
|- project2/
|- project3/
|- manage.py
|- project3/
Either way you do it, I don't think it is necessary to think about trying to get them all to run under the same single process. Django isn't designed to do that. It is designed to let you run multiple processes on the same project, for different sites, via the sites framework.
Upvotes: 3