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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:05:23+00:00 2026-06-07T23:05:23+00:00

I want to have unique values in my gae, so i read though the

  • 0

I want to have unique values in my gae, so i read though the docs and found that “transactions” are atomic.

https://developers.google.com/appengine/docs/python/ndb/transactions

class Account(ndb.Model):
    """"Required DB """
    username = ndb.StringProperty(required=True)
    password = ndb.StringProperty(required=True)
    mail = ndb.StringProperty(required=True)
    salt = ndb.StringProperty(required=True)
    date = ndb.DateTimeProperty(auto_now_add=True)

    name  = ndb.StringProperty()
    last_name  = ndb.StringProperty()
    phone_number  = ndb.IntegerProperty()
    postal  = ndb.IntegerProperty()
    city  = ndb.StringProperty()

    products = ndb.IntegerProperty(repeated=True)

    @ndb.transactional
    def create_account(self):
         acc = Account.query(Account.username==self.username)
         acc = tuple(acc)
         if len(acc)== 0:
             self.put()
         else:
             #yield error
             pass

I awalys get the same error

BadRequestError:

Only ancestor queries are allowed inside transactions.

My db model “Account” does not have any ancestors.
Shouldn’t it be the only “ancestor” ?

  • 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-07T23:05:24+00:00Added an answer on June 7, 2026 at 11:05 pm

    A way to circumvent this problem would be using the username as the key.

    @classmethod
    @ndb.transactional
    def create(cls, username):
        key = ndb.Key('Account', username)
        existing_user = key.get()
        if existing_user:
            raise ValueError
        else:
            new_instance = cls(key=key, username=username)
            new_instance.put()
        return new_instance
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I Want to have only unique values in a SharePoin List. To achieve this
I have two employee lists that I want to get only unique records from
I have a dictionary with non unique values and I want to count the
I have an array of hashes, and I want the unique values out of
I want the tds (textboxes) to have unique id 's, so that I can
I have a unique industrial application where I do not want the Windows CE
I have a sort of unique situation....I want to populate a ModelChoiceField based of
I have an object for which I want to generate a unique hash (override
I have this table: User id INT PK login VARCHAR UNIQUE I want to
Say I have something like this: <p> <br><br> <img id='unique'> <br> </p> I want

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.