Peewee KeyError: 'i' Peewee KeyError: 'i' flask flask

Peewee KeyError: 'i'


The issue lies within the Metadata for your Batch class. See peewee's example where order_by is used:

class User(BaseModel):    username = CharField(unique=True)    password = CharField()    email = CharField()    join_date = DateTimeField()    class Meta:        order_by = ('username',)

where order_by is a tuple containing only username. In your example you have omitted the comma which makes it a regular string instead of a tuple. This would be the correct version of that part of your code:

class Batch(Model):    initial_contact_date = DateTimeField(formats="%m-%d-%Y")    class Meta:        database = DATABASE        order_by = ('initial_contact_date',)