Forums

Server Error (500) when trying to upload an image for a model

Greetings When trying to upload an image used as a profile picture for the elements (rows) in a model (it's a "media" image, not a "static" one), I get a Server Error (500). I can't give any more detailed information about the error because I can't read my error.log for some reason, the newest error.log file is blank.

This is my upload:

def get_image_path(instance, filename):
    return os.path.join('/media/images', str(instance.id), filename)

class Artist(models.Model):
    name = models.CharField(max_length=255)
    soundcloud = models.URLField(max_length=255, blank=True, null=True)
    description = models.TextField()
    profile_picture = models.ImageField(upload_to=get_image_path, blank=True, null=True)
    current_roster = models.BooleanField(default=True)

    def __str__(self):
        return self.name.encode('utf8')

Could anyone help me please?

Thank you very much!

It looks like you're using Django there. Have you configured its logging at all? Our error logs only include stuff that isn't handled by your web framework, and Django is probably generating this one. I don't think it will log it anywhere useful by default if you have DEBUG mode switched off and you haven't configured logging. Do you have DEBUG set to False? If you try setting it to True temporarily, then reload the app, hopefully you'll get more information. Naturally you can always switch it off again once you've tracked down the problem.

this just happened to me about ten minutes ago check your errors log for me it was because pil wasn't installed

It looks like your site is using a virtualenv; if you do that, you need to install all modules that you use into it, because the system-wide installs of Python modules don't have any effect -- your virtualenv is a private environment for you.

So to install PIL (or rather, Pillow, which is the preferred version of PIL these days), start a Bash console inside your virtualenv using the link on the "Web" page, and run pip install pillow