[Answered ]-Is a directory Error in Django deployment

2đź‘Ť

âś…

Looks like profile.avatar.name evaluates to a blank string

So No file is being provided to os.remove to remove and It can’t remove a directory and raises OSError : See here: https://docs.python.org/2/library/os.html#os.remove

You can rectify this error by applying a conditional, which is what to be followed:

if profile.avatar.name:
 os.remove(settings.MEDIA_ROOT + "/" + profile.avatar.name)
👤Sahil kalra

0đź‘Ť

This just happened to me for another reason. Answering here in case it is not the situation above.

I had a file named “admin” in my static folder, which matched the directory “admin” where Django’s admin app stores its static files.

When running collectstatic it would conflict between those two. I had to remove my “admin” file (or rename it) so it didn’t clash.

In general, make sure your files don’t clash with any static file provided by other app.

👤Jj.

Leave a comment