colin_dev256 colin_dev256 - 8 days ago 7
AngularJS Question

Python: [object Object] showing up on page field

I am developing an angularjs app on google app engine however I have an issue displaying one of my

KeyProperty
fields
client
.

This is how the KeyProperty field is displaying (The other non KeyProperty elements are showing up fine);

NB: Post is 200 OK

enter image description here

model.py

class Project(ndb.Model):
projectID = ndb.IntegerProperty(required=True)
title = ndb.StringProperty(required=True)
description = ndb.StringProperty(required=True)
startAt = ndb.DateTimeProperty(indexed=True)
endAt = ndb.DateTimeProperty()
client = ndb.KeyProperty(kind='Client')

class Client(ndb.Model):
name = ndb.StringProperty()


home.html element

<div class="form-group">
<label>Client : </label>
<input type="text" ng-model="Project.Client" class="form-control"/>
</div>


In handler.py

def post(self):
r = json.loads(self.request.body)
print str(r)

cl = Client(name=r['Client']).put()
client_key = cl

g = Project(projectID=int(r['ProjectID']),
client=client_key,
description=r['Description'],
title=r['Title'],
startAt=datetime.strptime(r['StartAt'], '%Y-%m-%dT%H:%M:%S.%fZ'),
endAt=datetime.strptime(r['EndAt'], '%Y-%m-%dT%H:%M:%S.%fZ'))

project_key = g.put()


angular

eventClick: function (project) {
$scope.showSelected = true;

var fromDate = moment(project.start).format('DD/MM/YYYY LT');
var endDate = moment(project.end).format('DD/MM/YYYY LT');

$scope.Project = {
ProjectID : project.projectID,
Client : project.client,
Title : project.title,
Description: project.description,
Employees: project.employees,
StartAt : fromDate,
EndAt : endDate,
IsFullDay : false
}
$scope.ShowModal()
},


I am still learning my way to handling KeyProperties. Thanks for the help

UPDATE

This is the error I am getting when I type 'qwert' in the Client field;

enter image description here

Answer

I am talking about in your Python code. The error log should tell you what line of your code was expecting a string. That is where you need the .name

Comments