FILE_UPLOAD_TEMP_DIR ignored on Windows?
|Reported by:||spkane||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||1.0|
|Severity:||Keywords:||FILE_UPLOAD_TEMP_DIR, SuspiciousActivity, Windows|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
When running Django 1.0 on Windows XP, I am getting an error when uploaded a headshot (image), while adding an author from the Chapter 6 tutorial in the Django Apress book. The error is related to "SuspiciousActivity", however my FILE_UPLOAD_TEMP_DIR directory is set to 'c:\djcode\mysite\temp' which should be safe. The issue, based on the error message, however seems to be that it is actually trying to save the image into /tmp, which of course causes a problem on Windows. I was able to get this working for myself by patching django\db\models\fields\files.py.
I am a pretty new Python programmer and I realize that this patch is a hack, since I am forcing something to happen here and possibly over ridding a legitimate value. I tried to change the initial init from upload_to= to upload_to=settings.FILE_UPLOAD_TEMP_DIR. However that didn't work, so it seems that the class is getting initialized with a value, but it is the wrong value, and I could not trace the code back any further. This patch works for me, but it would be nice to have a proper solution in the future.
Change History (4)
comment:1 follow-up: 2 Changed 8 years ago by
|Patch needs improvement:||unset|
|Status:||new → closed|