Solution - Typeerror '<' not supported between instances of 'datetime.datetime' and 'str' while Sorted()


sorted(self.total_played_game_details, key=lambda i: i['start_datetime'], reverse=True)

Type error '<' not supported between instances of 'datetime.datetime' and 'str' 


Solution

from datetime import datetime

sorted(self.total_played_game_details, key=lambda i: datetime.strptime(str(i['start_datetime']), "%Y-%m-%d %H:%M:%S"))

Comments

Popular posts from this blog

ERR: error parsing query: found influx, expected SELECT, DELETE, SHOW, CREATE, DROP, EXPLAIN, GRANT, REVOKE, ALTER, SET, KILL at line

How To Convert Html File/URL/String Into Image Using Python

How to get Full URL or get absolute url In Django