3

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>

1 Answer 1

2

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\
Sign up to request clarification or add additional context in comments.

7 Comments

Hi, Thanks for your reply! I tried to change Alias to /static/ E:\Bitnami\djangostack-1.6.7-1\apache2\static\, however, I'm still getting 404.
Have you restarted apache service every time you change something? In my case it's always the only way to make apache see changes.
Yep, I've tried to restart it everytime I made a change. Is there a way to debug this except HTTP 404?
As far I as know, there is no way to do that. Maybe try to delete this all Directory section for static folder. In my case I do not need it in configuration file
Ah... When I do remove my all directory. It will give me 403 forbidden error. I think there is something funky with the config file then?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.