Using Django as a cappuccino backend

I am new to Django and Cappuccino. I have a Django site setup and is done through Apache via mod_wsgi. I want to use Django as the backend for a Cappuccino app, but installing VirtualHost in Apache and mod_wsgi to serve the Django app serves static files from somewhere other than the normal web root (e.g. http://example.com/media/ or http: //media.example.com ).

How do I set up the environment so that http://example.com serves my Javascript / HTML / CSS Cappuccino files and also allows me to use the typical Django url system to create endpoints for AJAX calls (for example http://example.com / some / json / )?

+2


source to share


2 answers


Did you read:

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



This addresses various aspects of using WSGIScriptAlias ​​for mod_wsgi and Alias ​​for static files.

I suggest that you make sure you read this or re-read it and then post what config you tried already as it will help explain what you are trying to do and then just fix it.

+1


source


Here is the config 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 setup:

<VirtualHost *:80>
    ServerAdmin webmaster@mysite.local
    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've limited my extension to 5 characters or less) as a static file, and all other requests will be sent to my Django app.

0


source







All Articles