29 Oct 2008 henrique   » (Observer)

SuspiciousOperation on Django with FileField?

Just a quick tip. I was wondering why this error happens, but until I got the time to investigate it I just commented out the column on the model and moved on, but now (after a 5 minutes search at the django's code) I found the reason and I want to share it. The complete error message is:

Exception Type:	SuspiciousOperation
Exception Value:	
Attempted access to '/Users/henrique/tmp/uploads/half_logo.png' denied.

Suppose the project directory (where manage.py and its friends are) is: /Users/henrique/dev/someproject/. The problem is quite simple: since the directory specified for the parameter upload_to is /Users/henrique/tmp/uploads and it has a "base path" different of the place where the project is (/Users/henrique/dev/someproject/), django forbides access to it. It has a bit of reason to be, since django is avoiding you from future headaches (pollutioning directories outside your sandbox, for instance).

Of course, to fix it you just need to change the upload_to parameter to something like /Users/henrique/dev/someproject/uploads, that is inside the project's sandbox.

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!