On 11 Sep 2012, at 2:54 PM, jc <j-cl...@lineone.net> wrote: > I have a file "app/static/docs/Report 2008 12.pdf" i.e. it is in a subdir of > static and the filename has spaces. > I use URL('static', 'docs', 'Report 2008 12.pdf') to generate the link. > When I click the link the browser address bar contains > http://localhost:8000/static/docs/Report%202008%2012.pdf (which looks good to > me) but the browser window gets "invalid request". > What am I doing wrong? > > Or to re-phrase - what url should I use to serve static documents from the > docs sub directory of the static directory if the filename has spaces in it? > Files with no spaces in the filename work fine. > > The only weird thing in my routes.py is map_hyphen = True. > > Many thanks for your help. >
By default, the router doesn't allow spaces; the default regex for static URLs is file_match = r'([-+=@$%\w]+[./]?)+$', # legal static subpath You can add a space if you like: file_match = r'([-+=@$%\w ]+[./]?)+$', # legal static subpath --