active = User.select().where(User.active == True)
try:
    user = active.where(User.username == request.form['username']).get()
except User.DoesNotExist:
    return make_response(jsonify({'error': 'Bad request'}), 400)
How to change UserDoesNotExist SELECT behavior in Flask-peewee - python & mysql