0

I followed the tutorial on setting up Django with Apache and mod_wsgi (on Windows), but whenever I try to access a static file, I get the following error: TypeError at /static/js/map.js object of type 'NoneType' has no len()

This has something to do with document_root:

C:\Python27\lib\site-packages\django\core\handlers\base.py in get_response
TypeError("object of type 'NoneType' has no len()",)
resolver_match  (func=<function serve at 0x0A4FEF70>, args=(), kwargs={'path': u'js/map.js', 'document_root': None}, url_name='django.views.static.serve', app_name='None', namespace='')

Why is this happening, where do I need to set 'document_root'?

Some more info:

Exception Location: C:\Python27\Lib\ntpath.py in splitdrive, line 114
Python Executable:  C:\xampp\apache\bin\httpd.exe
Python Version: 2.7.8

C:\Python27\Lib\ntpath.py in join
result_drive, result_path = splitdrive(path) ...
▼ Local vars
Variable    Value
paths       (u'js/map.js',)
path        None
autonomy
  • 1,165
  • 1
  • 12
  • 18

1 Answers1

0

I figured it out, it wasn't a Django error, it was just me being stupid (as it always is) with the Apache configuration:

# NOTE: Where filenames are specified, you must use forward slashes
# instead of backslashes (e.g., "c:/apache" instead of "c:\apache").
# If a drive letter is omitted, the drive on which httpd.exe is located
# will be used by default.  It is recommended that you always supply
# an explicit drive letter in absolute paths to avoid confusion.

And I had an Alias like this:

Alias /static/ C:\path\static\

It should've been

Alias /static/ C:/path/static/

Which is strange, because the WSGIScriptAlias directive using backslashes worked.

autonomy
  • 1,165
  • 1
  • 12
  • 18