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

  • Home
  • SEARCH
  • 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 8365633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:42:19+00:00 2026-06-09T12:42:19+00:00

I have this class: class Contract(db.Model): book_number = db.IntegerProperty(required = True) initial_page = db.IntegerProperty(required

  • 0

I have this class:

class Contract(db.Model):
    book_number = db.IntegerProperty(required = True)
    initial_page = db.IntegerProperty(required = True)
    final_page = db.IntegerProperty(required = True)
    contract_type = db.StringProperty(required = True)
    parties = db.ListProperty(int)
    date = db.DateTimeProperty (required = True, auto_now = True, auto_now_add = True)

class ContractingParty(db.Model):
    person = db.ReferenceProperty(Person, required=True, collection_name="party_to_contracts")
    contract = db.ReferenceProperty(Contract, required=True)
    condition = db.StringProperty()

I use this code to create an entity named Contract which parties property is an empty list:

    parties = []
    contract_record = Contract(book_number = int(numBook),
                               initial_page = int(numInitialPage),
                               final_page = int(numFinalPage),
                               contract_type = choosed_contract_type,
                               parties = parties)
    contract_record.put()

But I have to populate the parties property with IDs of ContractingPerson entitty. So, in other part of the code, I uptade the parties property of Contract entity, this way:

contracting_party_record = ContractingParty(person = person_key,
                                                      contract = contract_key,
                                                      condition = get_condition)
contracting_party_record.put()
contracting_party_id = contracting_party_record.key().id()
contract = Contract.get_by_id(contract_id)
contract.parties.append(contracting_party_id)
#contract.parties.extend(contracting_party_id)
contract.put()

But when I query datastore, this way:

parties = db.GqlQuery("SELECT * FROM ContractingParty WHERE contract =:c_key", c_key = contract_key).fetch(20)

I got only the last ContractingParty entity I’ve create. It seems that contract.parties.append(contracting_party_id) is replacing the old list with the new one. Then, I tried to use contract.parties.extend(contracting_party_id). But, now, I got this error:

File "C:\Users\Py\Desktop\contract\main.py", line 363, in post
    contract.parties.extend(contracting_party_id)
TypeError: 'long' object is not iterable

How to fix that?

  • 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-09T12:42:20+00:00Added an answer on June 9, 2026 at 12:42 pm

    appending items on the list like contract.parties.append(contracting_party_id) does not replace the previous list it shouldn’t do it in your case too.

    what you want to do is using append instead of extend.

    while extend expects an iterable like another list, append adds an item to the list.

    >>> l = [1,2,3]
    >>> l.append(4)
    >>> l
    [1, 2, 3, 4] 
    
    >>> l = [1,2,3]
    >>> l.extend([4,5,6])
    >>> l
    [1, 2, 3, 4, 5, 6]
    >>> 
    

    here the docs: http://docs.python.org/tutorial/datastructures.html

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

Sidebar

Related Questions

I have this class: class Contract(db.Model): book_number = db.IntegerProperty(required = True) initial_page = db.IntegerProperty(required
I have this two classes: class Person(db.Model): person_name = db.StringProperty(required = True) #gender =
I have this database in GAE: class Contract(db.Model): # I renamed Act as Contract
I have this class which i would like to map: public class Contract {
I have a simple model for a contract: public class Contract { public int
Hi I have models like this : public class Person extends Model { ...
I have a model like this. #models.py class Payment(models.Model): unit_price = models.DecimalField(max_digits=12, decimal_places=2) discount
I have these tables: class Contract(models.Model): project = models.ForeignKey(Project) start_date = models.DateField() agreed_contacts =
I have the following model : class Contract { string ContractID{get;set;} ICollection<Part> Parts{get;set;} }
I have models with many to many relationships like this: class Contact(models.Model): name =

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.