Answer the question
In order to leave comments, you need to log in
How is it more convenient to pass a bunch of arguments to the template engine?
Hello, in general, the problem is, how to pass a bunch of arguments to the template more conveniently? That is, for prime there is a function that does something and everything ends in cozza
return render_template("index.html",arg1 = '1 arg',arg1000000 = 'arg100000000' )
Answer the question
In order to leave comments, you need to log in
Do this:
tpl_params = {...} # сколько угодно строк, заполняющих dict.
return render_template("index.html", **tpl_params)
Passing a lot of data to a view is a very bad practice.
Limit yourself to a maximum of 2 variables.
Most likely you are writing code in the controller that should be in the model, hence the bunch of extra variables.
Get into refactoring and give up this idea of yours.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question