简体   繁体   中英

show images on the templates of django using google app engine

i am using google app engine with django to make a small application that it has these features

  1. upload images,
  2. show images,
  3. minipulate images (rotate)

well after finishing part 1, now i am somewhere stuck in part 2 where i need to show images.
i did everything i retrieved the image keys, but the images are not showing.
only the titles of the images i saved in the datastore.

here is my code:

    <ul>
        {% for image in image.all %}
            <li>{{ image.title }}   </li>
            <li> <img  src="/pictures/models.{{image.key}}"/>   </li>
        {% endfor %}
    </ul>

Assuming

  • You uploaded the images to the blobstore
  • image.key is the blobstore key
  • You have a handler named BlobstoreImageHandler for /pictures/models\.(.*)/

Then you'd do something like

class BlobstoreImageHandler(blobstore.handler.BlobstoreDownloadHandler):
  def get(self, resource):
    resourse = str(urllib.unquote(resource))
    blob_info = blobstore.BlobInfo.get(resource)
    self.send_blob(blob_info)

which is straight out of http://code.google.com/appengine/docs/python/blobstore/overview.html#Serving_a_Blob

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM