Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8819157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:17:03+00:00 2026-06-14T05:17:03+00:00

I am migrating from db to ndb. There is a function to dynamically serve

  • 0

I am migrating from db to ndb. There is a function to dynamically serve images in a path. In DB, i pass entity key(i.key()) as img_id and using db.get(key) I get the image.

For NDB, i tried to pass key (i.key) and entity key(i.key.urlsafe()) to pass. But both these cases i get ‘unicode’ object has no attribute ‘get’ error.

**DB:**
def get(self):
image = db.get(self.request.get('img_id'))

**HTML**
<a class="post-title" href ="{{permalink}}">{{i.content}}</a>
<img src="/img?img_id={{i.key}}"></img>

**NDB**
class ImageHandler(BlogHandler):
def get(self):
    img=self.request.get('img_id')
    image=img.get()
    if image.image:
        self.response.headers['Content-Type'] = 'image/png'
        self.response.out.write(image.image)
    else:
        self.response.out.write('No image')     

I couldn’t able find the mistake in this. Am i passing wrong type for key in key.get()?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T05:17:06+00:00Added an answer on June 14, 2026 at 5:17 am

    You could try the following:

    HTML

    <a class="post-title" href ="{{ permalink }}">{{ i.content }}</a>
    <img src="/img?img_id={{ i.key.urlsafe() }}"></img>
    

    NDB

    class ImageHandler(BlogHandler):
    def get(self):
        img_key = ndb.Key(urlsafe=self.request.get('img_id'))
        image = img_key.get()
        if image.image:
            self.response.headers['Content-Type'] = 'image/png'
            self.response.out.write(image.image)
        else:
            self.response.out.write('No image')  
    

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am migrating from RichFaces 3.3 to RichFaces 4.1. In RichFaces 3.3 there was
Are there tools for migrating from one virtual machine type to another? E.g let's
Migrating from Subversion to Git using svn2git (which internally uses git-svn) I'd like to
I'm considering migrating from Subversion to Git at work, and would like to get
we are migrating from WebLogic web-services to Spring-WS (1.5.X). There is currently one issue
I'm migrating from Hibernate to OpenJPA. And there are many entities with annotations like
We are migrating from APE to socket.io. So far, so good, but... is there
We're migrating from Bugzilla to Redmine and there's one feature of bugzilla which I'm
In a program I am migrating from vb6 to VB.net, there are three Line
We have a system that is migrating from an older VARCHAR using LIKE setup

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.