+1  A: 

Make multiple django projects, each with a single app (frontend for example) and use django's url mapping to do something like this:

from django.conf.urls.defaults import patterns, include

urlpatterns = patterns('',
    url(r'^/', include('myproj.frontend.urls')
)

I use this, and it comes off without a hitch.

If you're asking for a full-fledged tutorial/walkthrough on setting something like this up, I'm sorry I don't have that. I just followed along the Django documentation and came up with this.

Bryan Ross
+1  A: 

One approach is to deploy the applications to Apache running under mod_wsgi in daemon mode. Documentation can be found here: http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango

Jason Jenkins
Daemon mode by itself it not the solution if they are talking about different projects.
Graham Dumpleton
+5  A: 

In your question, you seem to be using projects and apps interchangeably. They mean separate things in Django. A project includes the setup file, database configuration, and overall urlconf, and is what you want at the root of your domain. An app is an individual functional piece of code that (generally) does one task.

If you want to deploy multiple apps, you want to create a single project and copy each app into the project directory. If you look at the tutorial, you'll see how to include an app in the urlconf. Simply repeat that for each one, making sure that the regexes are correct.

The key point here is that you get apache working for your overall django project, and then you use Django's internal urlconf to set up where each app may be accessed. Don't try to run multiple projects under the root of the same url - that's almost certainly a sign that you're doing it wrong.

If you're referring to running multiple projects under a single domain, we solve this problem is with subdomains.

Since the Django projects we're building are (generally) designed to live at the root of the domain when they're actually deployed, if you use app1.example.com and app2 etc., you can test like you will be deploying, in the root of each domain. You can configure subdomains exactly as you would configure top level domains, and then moving to your final deploy is easy.

If you're trying to actually deploy applications like that, create a single overarching Django project and use the urlconfs to include each Django app at a different sub url.

Paul McMillan
Thanks Paul. You're right, I did confusingly interchange projects and apps. I meant that I'd like to deploy several Django projects on the server. Sorry for the confusion.Was kind of hoping that there was a way to deploy multiple Django projects on the same server similar to how one might do that with PHP... essentially creating a new URL path under the same domain. I understand that the mechanics of a PHP a setup and a Django setup are completely different, but was kind of hoping for the same end result: http://mydomain.com/project1/ http://mydomain.com/project2/. ...more...
Joe J
I was hoping to avoid subdomains, as I'd prefer to eliminate the need for a dependency on an external nameservice (DNS, hosts file). This setup will be useful mostly to me as a testing environment on my home network with only IP addresses (no nameservice running), where I would install maybe a dozen or so different Django projects in different stages of development for testing purposes.
Joe J
For the record, it *is* possible to run Django projects side by side at specific url paths on the same domain, but it's not pretty to set up.
Gabriel Hurley
Gabriel, don't know what hosting mechanism you are using to claim it is not pretty to set up. With mod_wsgi it is very easy and in no way 'not pretty'.
Graham Dumpleton
If it's really just for home and testing purposes, have you considered putting them on different ports? That again makes it super-easy to differentiate them, and you're using similar urlconfs to what you would in a production environment.
Paul McMillan
+1  A: 

Let's get straight on the terminology.

Most examples you see on the web are for one Django project per domain. Each project can hold several applications.

From here on I'll assume you are referring to deploying several projects on a single domain. (Otherwise - your question is nullified).

This can easily be solved with proper deployment per directory (this depends on what deployment method you are using), and ensuring your URLs are not assuming that they exist on the domain root.

Yuval A
Yes, I am referring to deploying multiple projects per domain. Sorry for the confusion. Thanks for your response
Joe J
+1  A: 

Others have covered use of multiple applications within one Django project. If however you meant projects and/or only have one application in each project, then the simple answer is to use a separate WSGIScriptAlias directive for each project if using mod_wsgi. Each such project may optionally be delegated to a mod_wsgi daemon process group so as to allow each to be separately restarted without restarting the whole of Apache, but daemon mode is an extra thing that can be done and not the solution itself.

Graham Dumpleton
Awesome, I'll do some research on the WSGIScriptAlias directive. Thanks for the pointer.
Joe J
+2  A: 

I've been in situations where I couldn't use subdomains, and the way to handle this with Django is pretty simple actually.

Pretty much everything in your settings file will be just like a regular Django app, with the exception of making sure these settings include your project path:

MEDIA_URL = 'http://192.168.0.1/gallery/media/'
ADMIN_MEDIA_PREFIX = '/gallery/admin_media/'
SESSION_COOKIE_PATH = '/gallery'
LOGIN_REDIRECT_URL = '/gallery/'
LOGIN_URL = '/gallery/accounts/login/'
LOGOUT_URL = '/gallery/accounts/logout/'

The SESSION_COOKIE_PATH is critical to prevent all your apps on the same domain from rewriting each others cookies.

The above instructions should cover the Django side, but there's still more work to do on the web server side. For example, if you use apache+mod_wsgi you'll need to make sure each project has their own wsgi script that is loaded like this:

WSGIScriptAlias /gallery /path/to/gallery/apache/gallery.wsgi
Alias /gallery/media /path/to/gallery/media
Alias /gallery/admin_media /path/to/gallery/venv/lib/python2.6/site-packages/django/contrib/admin/media

etc.

Van Gale
Thanks for this great example. Good to note about the cookie path also!
Joe J
I was able to get a project running using this approach.
Joe J