couchDB-Python storing Date Value
Question: I was following the CouchDb tutorial from
<http://packages.python.org/CouchDB/mapping.html>. This seems to be outdated
since the modules dont work as per the program. So I just re wrote the CouchDB
python script to store few values and here is my script. But when I lookup the
CouchDb database I can find the name and age but the **date value is not
stored**. Can someone tell me how to go about doing this? Also is there an
updated python CouchDB tutorial?

    
    
    from couchdb import Server, Document
    from couchdb.mapping import TextField, IntegerField, DateTimeField 
    import datetime
    
    class Person(Document):
        name  = TextField()
        age = IntegerField()
        added = DateTimeField(default=datetime.datetime.now())
    
    if __name__ == '__main__':
        server = Server('http://localhost:5984')
        try:
            db = server.create('person')
        except Exception:
            db = server['person']
    
        person = Person(name='John Doe', age=42)
        db.save(person)
    


Answer: The Couchdb example refers to a default value of `datetime.now` but you are
using `datetime.datetime.now()`. The extra `datetime` is not an issue but you
might want to consider using `from datetime import datetime` for readability.

The issue is that you are calling a function and returning its value, while
the example passes a function object which the Couchdb can call anytime it
needs a default value.

Get rid of the two parentheses and you should be OK.

