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(str)
date = db.DateTimeProperty (required = True, auto_now = True, auto_now_add = True)
And at this line of my code:
contract.parties = old_parties.append([str(person_id), person_condition])
From this block:
(...)
party = []
contract_record = Contract(book_number = int(numBook),
initial_page = int(numInitialPage),
final_page = int(numFinalPage),
contract_type = choosed_contract_type,
parties = party)
contract_record.put()
contract_key = contract_record.key()
contract_id = contract_record.key().id()
submit_button = self.request.get('submit_button')
if submit_button:
if (person_name and valid_name(person_name)) and (user_SSN and valid_SSN(user_SSN)):
person_record = Person(person_name = person_name,
nacionality = user_nacionality,
profession = user_profession,
marital_status = user_marital_status,
driver_license = int(user_driver_license),
SSN = int(user_SSN),
address = address)
person_record.put()
person_key = person_record.key()
person_id = person_record.key().id()
contract = Contract.get_by_id(contract_id)
old_parties = contract.parties
contract.parties = old_parties.append([str(person_id), person_condition])
contract.put()
I got this error:
File "C:\Users\Py\Desktop\contract\main.py", line 351, in post
contract.parties = old_parties.append([str(person_id), person_condition])
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\db\__init__.py", line 614, in __set__
value = self.validate(value)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\db\__init__.py", line 3435, in validate
value = super(ListProperty, self).validate(value)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\db\__init__.py", line 641, in validate
raise BadValueError('Property %s is required' % self.name)
BadValueError: Property parties is required
My goal is: create an object contract with a empty list in its parties property. After that, I’d like to append new lists [person_id, person_condition] to that empty list, this way: [ [person_id, person_condition], [person_id2, person_condition2],...]
I’d like to know what is producing this error and how to fix it to achieve my goal.
Thanks for any help!
I’m not sure if this is what’s causing the GAE engine you see, but
appendappends to the list in place and returns None. So you want to docontract.parties.append([str(person_id), person_condition]). The way you are doing it, you wind up settingcontract.partiesto None.