Django The 'image' attribute has no file associated with it

后端 未结 7 952
萌比男神i
萌比男神i 2020-12-01 07:09

When a user registers for my app.I receive this error when he reaches the profile page.

The \'image\' attribute has no file associated with it.
Exception Typ         


        
7条回答
  •  佛祖请我去吃肉
    2020-12-01 07:47

    Not exactly what OP was looking for, but another possible solution would be to set a default value for ImageField:

     class Profile(models.Model):
        # rest of the fields here
        image = models.ImageField(
            upload_to='profile_pics/',
            default='profile_pics/default.jpg')
    

提交回复
热议问题