Reputation: 5889
This seemingly perfect Google App Engine code fails with a KindError.
# in a django project 'stars'
from google.appengine.ext import db
class User(db.Model):
pass
class Picture(db.Model):
user = db.ReferenceProperty(User)
user = User()
user.put()
picture = Picture()
picture.user = user
# ===> KindError: Property user must be an instance of stars_user
The exception is raised in google.appengine.ext.db.ReferenceProperty.validate:
def validate(self, value):
...
if value is not None and not isinstance(value, self.reference_class):
raise KindError('Property %s must be an instance of %s' %
(self.name, self.reference_class.kind()))
...
Upvotes: 1
Views: 360
Reputation: 5889
Turns out that I was importing the model in admin.py as
from frontend.stars.models import Star
This line had contaminated the module namespace of Star
and the isinstance
query was failing.
>>> user.__class__
<class 'frontend.stars.models.User'>
>>> Picture.user.reference_class
<class 'stars.models.User'>
Upvotes: 1