While there probably won't be any problem in this case no matter what the order, you probably want login_required
to execute first so that you don't make queries and paginate results that will just get thrown away.
Decorators wrap the original function bottom to top, so when the function is called the wrapper added by each decorator executes top to bottom. @login_required
should be below any other decorators that assume the user is logged in so that its condition is evaluated before those others.
@app.route()
must always be the top, outermost decorator. Otherwise the route will be registered for a function that does not represent all the decorators.
The broader answer is that it depends on what each of the decorators are doing. You need to think about the flow of your program and whether it would make logical sense for one to come before the other.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…