I am trying to show image using template in Django:
template.html:
<img src='{{ url }}' alt="" />
{{ url }} define in views.py
views.py:
blob_key =str(product.key())
url = images.get_serving_url(blob_key)
product – simple object, define in models.py:
class Product(db.Model):
name = db.StringProperty()
price = db.FloatProperty()
added = db.DateTimeProperty(auto_now_add=True)
image = db.BlobProperty(default=None)
After all, I get url = u'http://localhost:8080/_ah/img/ag5kZXZ-dmVydGlrYWwtM3INCxIHUHJvZHVjdBgEDA'
In admin console item with id = ag5kZXZ-dmVydGlrYWwtM3INCxIHUHJvZHVjdBgFDA, exist.
But in brawser i don’t see image.
Python 2.7
- What am I doing wrong?
- What other method to display image in GAE, using Django?
You seem to be using your Product instance’s key as the basis for the URL, rather than the key to the
imageblob. Surely you mean: