What is your MEDIA_ROOT
in settings.py
? From the back-trace, it seems you have set your MEDIA_ROOT
to /static/
.
This error is coming since Django is trying to access /static/
to which it has no access. Put an absolute pathname for MEDIA_ROOT
like C:/Documents/static/
and give full permissions to Django to access that directory.
That should solve your problem.
Addendum: Since your MEDIA_ROOT
seems to be OK, I am guessing that you are using MEDIA_URL
for deleting the file instead of MEDIA_ROOT
. Indeed, from the error it seems that Django was trying to access the /static/files/8.nzb
and was denied access. Clearly, /static/
is your MEDIA_URL
and not your MEDIA_ROOT
. The model methods should never try accessing the files using the MEDIA_URL
. I am sure a review of your code will spot the error.
Update: I skimmed your code and it seems you are setting File.nzb
to %(1)sfiles/%(2)s.nzb' % {'1': settings.MEDIA_URL, '2': self.pk}
which uses its MEDIA_URL
and then in the delete()
method you are calling the delete()
method of the super-class of File
as super(File, self).delete()
which is obviously wrong as it will try deleting File.nzb
and will try accessing the file through the MEDIA_URL
. Fixing that will get rid of the error. I will leave the exact solution as an exercise to you :)