default=datetime.datetime.now
这样是能连时间一起获取的,但是我想要的效果的单单获取日期,不带时间,我试过
datetime.date.day
结果报
sqlalchemy.exc.OperationalError: (_mysql_exceptions.OperationalError) (1292, "Incorrect datetime value: '<attribute 'day' of 'datetime.date' objects>' for column 'join_time' at row 1") [SQL: u'INSERT INTO music_user (email, username, _password, avata r, join_time, gender) VALUES (%s, %s, %s, %s, %s, %s)'] [parameters: ('char_web@163.com', 'char1998', 'pbkdf2:sha1:1000$5CkzkpB1$38c28dfaa9556649857ae6442b8cbe2e29e8890d', None, <attribute 'day' of 'datetime.date' objects>, 3)]
datetime.datetime.day
报了
sqlalchemy.exc.OperationalError: (_mysql_exceptions.OperationalError) (1292, "Incorrect datetime value: '<attribute 'day' of 'datetime.date' objects>' for column 'join_time' at row 1") [SQL: u'INSERT INTO music_user (email, username, _password, avata r, join_time, gender) VALUES (%s, %s, %s, %s, %s, %s)'] [parameters: ('char_web@163.com', 'char1998', 'pbkdf2:sha1:1000$SNKS5Gsm$ba00dd797aa0ac25049bef2dc2042790915cb8be', None, <attribute 'day' of 'datetime.date' objects>, 3)]
datetime.date
sqlalchemy.exc.StatementError: (exceptions.TypeError) Required argument 'year' (pos 1) not found [SQL: u'INSERT INTO music_user (email, username, _password, avatar, join_time, gender) VALUES (%s, %s, %s, %s, %s, %s)'] [parameters: [{'username': 'char1998' , '_password': 'pbkdf2:sha1:1000$kCRVx1le$1a8afcf0e9640b0fe3181929cc02a5e0d07e0c0d', 'email': 'char_web@163.com', 'avatar': None}]]
datetime.datetime.date()
TypeError: descriptor 'date' of 'datetime.datetime' object needs an argument
datetime.datetime.date
AttributeError: 'method_descriptor' object has no attribute '__module__'
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.