Django choking oddly on some static media

Posted by Edan Maor on Stack Overflow See other posts from Stack Overflow or by Edan Maor
Published on 2010-06-14T11:00:24Z Indexed on 2010/06/14 11:02 UTC
Read the original article Hit count: 274

Filed under:
|
|

My situation: I'm serving static media via Django on my dev machine.

On some files that I try and load, I get back this error:

Traceback:    
File "c:\Program Files\Python26\Lib\site-packages\django\core\handlers\base.py" in get_response    
92.                 response = callback(request, *callback_args, **callback_kwargs)    
File "E:\Stack2Blog\src.hg\stack2blog\..\stack2blog\stack2blogapp\views.py" in userpage    
71.         so_user = site.user(userid)    
File "E:\Stack2Blog\src.hg\stack2blog\..\stack2blog\stack2blogapp\stackexchange.py" in user    
476.         u, = self.users((nid,), **kw)    
File "E:\Stack2Blog\src.hg\stack2blog\..\stack2blog\stack2blogapp\stackexchange.py" in users    
481.         return self._get(User, ids, 'users', kw)    
File "E:\Stack2Blog\src.hg\stack2blog\..\stack2blog\stack2blogapp\stackexchange.py" in _get    
471.         return self.build(root, typ, coll, kw)    
File "E:\Stack2Blog\src.hg\stack2blog\..\stack2blog\stack2blogapp\stackexchange.py" in build    
448.         json = self._request(url, kw)    
File "E:\Stack2Blog\src.hg\stack2blog\..\stack2blog\stack2blogapp\stackexchange.py" in _request    
422.             dump = json.load(data)    
File "c:\Program Files\Python26\lib\json\__init__.py" in load    
264.     return loads(fp.read(),    
Exception Type: AttributeError at /userpage/362498    
Exception Value: 'str' object has no attribute 'read' 

I've traced it to specific files which don't work (by going to their specific urls).

Here's the odd part: changing the filename of the files makes them suddenly work. For example, I had a file called 'post.jpg', which gave this error. I renamed it to 'pos.jpg' and it worked. Back to 'post.jpg' and it gives the same error.

© Stack Overflow or respective owner

Related posts about python

Related posts about django