Flask-sqlalchemy with Blueprints – RuntimeError: No application found. Either work inside a view function or push an application context

Solution
class TicketForm(FlaskForm):
    requested_by = QuerySelectField(label='Requested by',
                                    query_factory=user_query(),
                                    allow_blank=False,
                                    get_label='full_name')
class TicketForm(FlaskForm):
    requested_by = QuerySelectField(label='Requested by',
                                    allow_blank=False,
                                    get_label='full_name')
def user_query():
        query = User.query()
        return query
@ticket.get('/ticket')
@ticket.put('/ticket')
@login_required
def ticket():
    form = TicketForm()

    form.requested_by.query = User.query.all()  # Added this

    print(current_app.app_context())
    return render_template('ticket.html', form=form)