Skip to content Skip to sidebar Skip to footer

Django Suspiciousoperation At /upload/ When Uploading A File

I'm developing a project in Django 1.5 and Python 2.7. While uploading a file Django raise an error message: SuspiciousOperation at /upload/ Attempted access to '\static\file\test

Solution 1:

The problem is this line in your models:

file = models.FileField(upload_to= "/static/file/")

You are passing an absolute path, which would mean "store this in C:\static\file\", which is not a subdirectory of your MEDIA_ROOT. You can change the upload_to parameter either to an absolute path that starts with C:/Users/User/Desktop/site_is/app_is/static/file/, or a relative path:

file = models.FileField(upload_to= ".")

Post a Comment for "Django Suspiciousoperation At /upload/ When Uploading A File"