code: def _serialize(self, value, attr, obj):
          
          # this might be an optional field
          if value:
              value = value.id
  
          return super(ForeignKeyField, self)._serialize(value, attr, obj)
docs: Grab the ID value off the Peewee model so we serialize an ID back.