1👍
✅
You’re trying to upload the image to img/
, which is not a valid Windows path (backslash separators). If you want it to work in both Linux and Windows, you could do something like:
import os
def get_image_path(instance, filename):
return os.path.join("img", filename)
class Page(models.Model):
...
img = models.ImageField(upload_to=get_image_path, blank=True, null=True)
...
Source:stackexchange.com