1👍
MEDIA_URL
is a url, not a file path. You need:
MEDIA_URL = "images/"
You also need to change the upload_to
field, otherwise your images will go into /flipdiscountApp/images/images/
.
You should also use the url
property of the ImageField
:
def get_image_url(self):
"""Method to return store image for admin panel"""
return '<img src="%s" height="150" width="150"/>' % self.storeImage.url
get_image_url.allow_tags = True
I also changed your method name as per the python style guide.
0👍
First the code to get the project’s path is wrong:
PROJECT_DIR_PATH = path.dirname(path.dirname(__file__))
You need to get an absolute path and calling dirname
twice on __file__
does not make sense:
PROJECT_DIR_PATH = path.dirname(path.normpath(path.abspath(__file__)))
Second you also need to fix MEDIA_URL like
MEDIA_URL = "/images/"
- [Answer]-How to get unique values in Django models?
- [Answer]-Django – customised validation error
- [Answer]-Working with pending trigger event in Django 1.4
- [Answer]-ManyToMany Relation using Django
Source:stackexchange.com