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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:46:30+00:00 2026-05-13T21:46:30+00:00

I need to update a record in the datastore, but instead of updated record

  • 0

I need to update a record in the datastore, but instead of updated record I get always a new record.

My model:

class PageModel(db.Model):

    title = db.StringProperty()
    content = db.TextProperty()
    reference = db.SelfReferenceProperty()

    user = db.UserProperty(auto_current_user = True)    
    created = db.DateTimeProperty(auto_now_add = True)
    modified = db.DateTimeProperty(auto_now = True)

    type = db.StringProperty()
    template = db.StringProperty()
    position = db.IntegerProperty()
    hidden = db.BooleanProperty()
    historical = db.BooleanProperty()

My handler:

class EditHandler(webapp.RequestHandler):

   def post(self):
        if self.request.path[6:] == '':
            page_id = 8
        else:
            page_id = int(self.request.path[6:]) # path: /edit/35

        #id = self.request.get('id')
        CP = PageModel.get_by_id(int(page_id))
        key = CP.key()

        title = self.request.get('title')
        content = self.request.get('content')
        type = self.request.get('type')
        hidden = self.request.get('hidden')
        #position = self.request.get('type')

        reference = PageModel.get_by_id(int(self.request.get('reference')))

        template = self.request.get('template')
        if ".htm" not in template:
            template = "index.htm"


        #if title == '' or content == '':
          #doRender(self,'create_page.htm',{'error' : 'Please fill in all fields'} )
          #return

        #edited_page = PageModel(key=CP.key, title=title, content=content, type=type, reference=reference, template=template)
        edited_page = PageModel()

        edited_page.key = CP.key()
        edited_page.title = title
        edited_page.content = content
        edited_page.type = type
        edited_page.reference = reference
        edited_page.template = template

        edited_page.put()

There should be something wrong with edited_page.key = CP.key(), or what?!

  • 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-13T21:46:30+00:00Added an answer on May 13, 2026 at 9:46 pm

    Why are you created a new PageModel everytime? instead edit the one you got by id i.e. CP ? e.g.

    edited_page = CP     
    edited_page.title = title
    edited_page.content = content
    edited_page.type = type
    edited_page.reference = reference
    edited_page.template = template
    
    edited_page.put()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to update the primary key for a record but it's also the
I need this query - update last but one record. UPDATE changes SET checked=''
I need help extending a functional update query that performs calculations on one record
I need to update time info in a DateTime. I get a string in
I need to insert records, but if the records exist do a replace instead.
I need to update the primary ID value of a record in table_1 and
I am new to Ext JS and I need to update an old app.
I need to check if the item is in datastore before I update it.
I need to update a record in a database with the following fields [ID]
I need some SQL to update a record in a database if it exists

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.