Python Forum

Full Version: Jinja sort values from request.form
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi everyone,

I'm following this tutorial ->

I tried to have the value sorted in the result.html

I tried many way in result.html as in the .py file. nothing work.

In python I'm accustomed to use
but here it's not working any ideas how to solve this ?
Templates shouldn't have any logic in them really. Sort the data in your handler and pass it yo the template. What problem are you having in doing that?

I found the problem when I was using sorted() it returned a list an jinja (or flask) didn't like that.

so now in the .py file I use this ->

import collection
def result():
   if request.method == 'POST':
      collect = request.form
      return render_template("result.html",result= collections.OrderedDict(sorted(result.items())))