Reputation: 2457
I'm trying to use Django + Apache + WSGI on Windows.
I've been using the Bitnami stack so that it takes care of installation of Apache. I was able to put a Django Project on Django, however, it loads up the webpage without any static files (css, js). So I've opened the Apache logs and all the static files are shown as 404.
This is my httpd-app.conf:
<Directory "E:/Bitnami/djangostack-1.6.7-1/apps/django/django_projects/Dashboard_Web/Dashboard_Web">
Options +MultiViews
AllowOverride All
<IfVersion < 2.3 >
Order allow,deny
Allow from all
</IfVersion>
<IfVersion >= 2.3>
Require all granted
Options All
</IfVersion>
Options +ExecCGI
WSGIApplicationGroup %{GLOBAL}
<IfVersion < 2.3 >
Order allow,deny
Allow from all
</IfVersion>
<IfVersion >= 2.3>
Require all granted
Options All
</IfVersion>
Options All
AllowOverride All
Options Indexes FollowSymLinks
Options +ExecCGI
</Directory>
Alias /static/ 'E:/Bitnami/djangostack-1.6.7-1/apache2/static/'
<Directory 'E:/Bitnami/djangostack-1.6.7-1/apache2/static'>
<IfVersion < 2.3 >
Order allow,deny
Allow from all
</IfVersion>
<IfVersion >= 2.3>
Require all granted
Options All
</IfVersion>
Require all granted
Options All
AllowOverride All
Options Indexes FollowSymLinks
</Directory>
<Directory />
Require all granted
</Directory>
WSGIScriptAlias /Dashboard_Web 'E:/Bitnami/djangostack-1.6.7-1/apps/django/django_projects/Dashboard_Web/Dashboard_Web/wsgi.py'
This is my settings.py:
STATIC_URL = '/static/'
STATIC_ROOT = "E:/Bitnami/djangostack-1.6.7-1/apache2/static/"
For the static files, I've used python manage.py collectstatic
and it would generate all the static files "E:/Bitnami/djangostack-1.6.7-1/apache2/static/
", so I can automate it with Fabric
(so I don't need to update static files by typing python manage.py collectstatic
myself).
Alias seems to be pointing to the right folder, because it is searchable in Windows Explorer. So I'm not sure why this is happening, can anyone point me to the right direction?
Thanks.
Edit: This is what looks in an html page
<script type="text/javascript" src="/static/WebApp/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="/static/WebApp/login.js"></script>
<script type="text/javascript" src="/static/WebApp/bootstrap-3.2.0-dist/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/static/WebApp/zxcvbn-master/zxcvbn.js"></script>
<script type="text/javascript" src="/static/WebApp/jquery.pwstrength.bootstrap-1.2.2/dist/pwstrength-bootstrap-1.2.2.min.js"></script>
This is how I link to static files
{% load staticfiles %}
<script type="text/javascript" src="{% static 'WebApp/jquery-2.1.1.min.js' %}"></script>
<script type="text/javascript" src="{% static 'WebApp/index.js' %}"></script>
<script type="text/javascript" src="{% static 'WebApp/bootstrap-3.2.0-dist/js/bootstrap.min.js' %}"></script>
<script type="text/javascript" src="{% static 'WebApp/flot/jquery.flot.js' %}"></script>
<script type="text/javascript" src="{% static 'WebApp/DataTables-1.10.2/media/js/jquery.dataTables.min.js' %}"></script>
Upvotes: 3
Views: 1661
Reputation: 1534
In my case I needed to make only Alias for static file, in your case, my configuration will look like this:
WSGIDaemonProcess Dashboard_Web python-path=E:/Bitnami/djangostack-1.6.7-1/apps/django/django_projects/Dashboard_Web/
WSGIScriptAlias /Dashboard_Web E:/Bitnami/djangostack-1.6.7-1/apps/django/django_projects/Dashboard_Web/Dashboard_Web/wsgi.py process-group=Dashboard_web
Alias /static/ E:/Bitnami/djangostack-1.6.7-1/apache2/static/
<Directory E:/Bitnami/djangostack-1.6.7-1/apps/django/django_projects/Dashboard_Web/>
Order allow,deny
Allow from all
</Directory>
It's worth to use this WSGIDaemonProcess when you run more then one django application. Also your problem may be coz by your system, you may try to use "\" instead of "/", for example:
Alias /static/ E:\Bitnami\djangostack-1.6.7-1\apache2\static\
Upvotes: 2