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 1083059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:23:00+00:00 2026-05-16T22:23:00+00:00

I’m having trouble with my project. I have 2 models class UserPrefs(db.Model): user =

  • 0

I’m having trouble with my project. I have 2 models

class UserPrefs(db.Model):
    user = db.UserProperty()
    name = db.StringProperty()

class Person(db.Model):
    name = db.StringProperty()
    phone = db.PhoneNumberProperty()
    userPrefs = db.ReferenceProperty(UserPrefs)

class PersonHandler(webapp.RequestHandler): 
    def get(self): 
        users.get_current_user user = () 
        if user: 
            greeting = ...... 
        else: 
            greeting = ......

        if self.request.GET.has_key ('id'): 
            id = int (self.request.get ['id']) 
            person = models.Person.get = (db.Key.from_path ('Person', id)) 

            path = os.path.join (os.path.dirname (__file__), 'templates / doStuff.html') 
            self.response.out.write (template.render (path, locals (), debug = True)) 

        def post (self): 
            if self.request.get ('Person'): 
                id = int (self.request.get ('Person')) 
                person = models.Person.get (db.Key.from_path ('Person', id)) 
            else: 
                person= models.Person = () 

            data = forms.PersonForm date = (data = self.request.POST) 
            if data.is_valid (): 
                if self.request.get ('photo'): 
                    Person.foto db.Blob = (self.request.get ('photo')) 

                person.nome self.request.get = ('name') 
                person.apelido self.request.get = ('name') 
                person.unidade self.request.get = ('unit') 

                person.put () 
                self.redirect ('/ doSomeStuff') 
            else: 
                self.redirect ('doOtherStuff')

To See the data in database i use this handler:
class SeePersonHandler (webapp.RequestHandler): 
    def get (self): 
        users.get_current_user user = () 
        if user: 
            greeting = ...... 
        else: 
            greeting = ......

        person= db.Query(models.Pocente)
        persons = person.fetch(limit = 1) 

        path = os.path.join(os.path.dirname(__file__), 'templates/SeeStuff.html')
        self.response.out.write(template.render(path, locals(), debug = True))

Question:
I knows that the data is put corectly. I used the SDK Console with this url: http://localhost:8080/_ah/admin/datastore and the entity is created correctly. I don´t know what i am missing to retrieve the dadta already put

My Template:

{% if user %}
  {% if person%}
    <table align="center">
    <tbody>
    <tr>
      <td><input type="button" value="Criar Pessoa" onclick="redirect(3)" /></td>
    </tr>
    </tbody>
    </table>
    <table align="center">
    <tbody>
    <tr>
      <td colspan="2"><center><strong><p>O meu Curriculum Vitae</p></strong></center></td>
    </tr>
    <tr>
      <td>Nome: </td>
      <td>{{ person.name}}</td>
    </tr>
    <tr>
      <td>Apelido: </td>
      <td>{{ person.phone}}</td>
    </tr>
    <tr>
      <td></td>
      <td>
        <input type ="button" value="Editar" onclick="editarCv({{ person.key.id }})" />
      </td>
    </tr>
    </tbody>
    </table>
  {% endif %}
{% endif %}
  • 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-05-16T22:23:01+00:00Added an answer on May 16, 2026 at 10:23 pm

    Your code is a bit disorganised.
    Debugging is generally easier with better-organised code.

    Anyway, enough of the trash-talking.
    You’re assigning the result of a datastore query to persons…

    persons = person.fetch(limit = 1)
    

    …but then in your template you use person:

    <tr>
      <td>Nome: </td>
      <td>{{ person.name}}</td>
    </tr>
    <tr>
      <td>Apelido: </td>
      <td>{{ person.phone}}</td>
    </tr>
    

    It is difficult to tell if this is your only problem (I highly doubt it), but perhaps you can try fixing that and get back to us. Best of luck to you.

    Aside: instead of .fetch(limit=1) you can simply use .get() as mentioned in the documentation:

    get() implies a “limit” of 1. At most
    1 result is fetched from the
    datastore.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a

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.