views:

740

answers:

2

I'm new to both Django and Cappuccino. I have a Django site setup and running through Apache via mod_wsgi. I want to use Django as the backend for a Cappuccino application, but a VirtualHost setup in Apache and mod_wsgi to serve a Django application serves static files out of a different location than the normal web root (e.g. http://example.com/media/ or http://media.example.com).

How could I setup the environment so that http://example.com serves my Cappuccino Javascript/HTML/CSS files, while also letting me use the typical Django URL system to create endpoints for AJAX calls (e.g. http://example.com/some/json/)?

+1  A: 

Have you read:

http://code.google.com/p/modwsgi/wiki/ConfigurationGuidelines

This goes into various aspects of using WSGIScriptAlias for mod_wsgi and Alias directives for static files.

I'd suggest you ensure your read that, or reread it, and then post what configuration you have tried already as that will help explain what you are trying to do and can then just correct it.

Graham Dumpleton
A: 

Here is the configuration I came up with that works:

Django Media Settings:

MEDIA_ROOT = '/Users/Me/Development/Web Projects/mysite/mysite/public_html'
MEDIA_URL = 'http:/mysite.local/'
ADMIN_MEDIA_PREFIX = '/'

Apache VirtualHost Configuration:

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName mysite.local
    ErrorLog "/private/var/log/apache2/mysite.local-error_log"
    CustomLog "/private/var/log/apache2/mysite.local-access_log" common
    WSGIScriptAlias / "/Users/Me/Development/Web Projects/MySite/django.wsgi"
    <Directory "/Users/Me/Development/Web Projects/MySite/">
     Allow from all
    </Directory>
    AliasMatch ^/(.*\.[A-Za-z0-9]{1,5})$ "/Users/Me/Development/Web Projects/MySite/public_html/$1"
    <Directory "/Users/Me/Development/Web Projects/MySite/public_html">
     Order deny,allow
     Allow from all
    </Directory>
</VirtualHost>

Basically this setup will serve any request with a file extension (I limited mine to an extension of 5 characters or less) as a static file, and all other requests will go to my Django app.

macinjosh