Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Property timestamp must be a datetime, current is unicode #114

Open
WestForge opened this issue Jan 8, 2012 · 0 comments
Open

Property timestamp must be a datetime, current is unicode #114

WestForge opened this issue Jan 8, 2012 · 0 comments

Comments

@WestForge
Copy link

I've created a Document class as so:

class Base(Document):
... doc_schema = IntegerProperty(required=True)
... name = StringProperty(required=True)
... update = DateTimeProperty(required=True, auto_now=True)
... created = DateTimeProperty(required=True, auto_now_add=True)

I have some json returned by a db.get(doc_id)

{u'created': u'2012-01-07T18:17:39Z',
u'doc_schema': 0,
u'doc_type': u'test',
u'name': u'abc',
u'update': u'2012-01-07T18:17:39Z'}

I've also tried db.open_doc()

account = Base(some_json_doc)

Traceback (most recent call last):
File "", line 1, in
File "/home/user/env/local/lib/python2.7/site-packages/couchdbkit/schema/base.py", line 405, in init
DocumentSchema.init(self, _d, **kwargs)
File "/home/user/env/local/lib/python2.7/site-packages/couchdbkit/schema/base.py", line 113, in init
prop.property_init(self, value)
File "/home/user/env/local/lib/python2.7/site-packages/couchdbkit/schema/properties.py", line 95, in property_init
value = self.to_json(self.validate(value, required=False))
File "/home/user/env/local/lib/python2.7/site-packages/couchdbkit/schema/properties.py", line 304, in validate
(self.name, self.data_type.name, type(value).name))
couchdbkit.exceptions.BadValueError: Property update must be a datetime, current is unicode

having a little look at what was going on, it appears the validate method is being called before the to_python so yes it is a unicode string and not a datetime object

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants