Pass json object to another html

user13646253

I have a simple Flask application with just one table. So python code is irrelavantly simple:

@app.route('/')
def home():
    items = long_db_request()
    return render_template("index.html", items=items)


@app.route('/extended')
def extended():
    return render_template("animals.html")

And items is a huge JSON object.

I created a table which reflects that data:

<table>
        <tr>
        <th style="text-align:center">id</th>
        <th style="text-align:center">creation time</th>
        <th style="text-align:center">name</th>
        <th style="text-align:center">animals</th>
        <th style="text-align:center">number</th>
    </tr>
        {% for item in items %}
            <tr>
                <td> {{ item.id }} </td>
                <td> {{ item.time }} </td>
                <td>
                    <a href="{{url_for('extended', name=item.id )}}"> {{ item.name }} </a>
                </td>
                <td> {{item.group}} </td>
                <td>{{ item.group|length }}</td>
            </tr>
        {% endfor %}
    </table>

The table looks like: enter image description here

As you can see, column animal contains a lof of object which makes it all difficult to percieve. I want it to be like this enter image description here

which is a lot easier to get. And show animals is a link to another page, where a pure json exists.

How can I achieve this?

I followed the doc of jinja2 and Flask and found method url_for() but in that case I have to pass all my json in query which is unacceptable..

How can I jump from first image to exellent nice view of the second one?

working code with the first picture is place here

Thank you very much in advance!

P.S. I only saw one question here with rellevant topic, but it does not help me

J.G.

Instead of passing all the animals (e.g. cats) from one view to another, just pass the category cats to the next page.

The view function for the next page then selects all cats from the json, and passes the cats then to the detailed view.

So, on you overview page, you render links like species.html?cats (and so on), and when somebody clicks on these links the view function selects all cats, and then passes them into a render_template("species.html", species=cats) view.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From

Golang pass JSON object to a function

From Dev

C++ Pass an object into another object?

From Dev

Pass a Javascript Object to an HTML iframe (as an Object)

From Dev

Pass an HTML file object from one <input type = file> to another

From Dev

Pass data from html object to another according to its id in my data base

From Dev

Pass object to function in html in javascript?

From Dev

Pass json object one component to another vuejs

From Dev

How to pass the output of a Sequelize query to another function that will return a JSON object with express?

From Dev

pass values of json object in react native to another object

From Dev

Pass JSON object to onclick function

From Dev

Convert a JSON object to another JSON object in Java

From Dev

Accessing a JSON object inside another JSON object

From Dev

Pass custom object to another fragment

From Dev

how to pass json response from one html page to another html page using angularJs?

From Dev

How do I pass a JSON object from one controller to another(/view to view)?

From Dev

How to pass html options to another html file?

From Dev

converting json object in to another object

From Dev

Pass object to html String

From Dev

pass imageURI to another html page

From Dev

How to pass an object that is a member of another object using JSON string notation?

From Dev

How can I pass the same object to another method of another object?

From Dev

How to pass json array object from one javascript adapter to another javascript adapter?

From Dev

Python dump JSON object into another JSON object

From Dev

wrapping json object in another object

From Dev

Convert nested json object into another json object

From Dev

pass address of an object to another object C++

From Dev

Pass Python object as json to JavaScript

From Dev

pass value from object to another object in javascript

From Dev

Is there another way to pass an object to a function?

Related Related

  1. 1

    Golang pass JSON object to a function

  2. 2

    C++ Pass an object into another object?

  3. 3

    Pass a Javascript Object to an HTML iframe (as an Object)

  4. 4

    Pass an HTML file object from one <input type = file> to another

  5. 5

    Pass data from html object to another according to its id in my data base

  6. 6

    Pass object to function in html in javascript?

  7. 7

    Pass json object one component to another vuejs

  8. 8

    How to pass the output of a Sequelize query to another function that will return a JSON object with express?

  9. 9

    pass values of json object in react native to another object

  10. 10

    Pass JSON object to onclick function

  11. 11

    Convert a JSON object to another JSON object in Java

  12. 12

    Accessing a JSON object inside another JSON object

  13. 13

    Pass custom object to another fragment

  14. 14

    how to pass json response from one html page to another html page using angularJs?

  15. 15

    How do I pass a JSON object from one controller to another(/view to view)?

  16. 16

    How to pass html options to another html file?

  17. 17

    converting json object in to another object

  18. 18

    Pass object to html String

  19. 19

    pass imageURI to another html page

  20. 20

    How to pass an object that is a member of another object using JSON string notation?

  21. 21

    How can I pass the same object to another method of another object?

  22. 22

    How to pass json array object from one javascript adapter to another javascript adapter?

  23. 23

    Python dump JSON object into another JSON object

  24. 24

    wrapping json object in another object

  25. 25

    Convert nested json object into another json object

  26. 26

    pass address of an object to another object C++

  27. 27

    Pass Python object as json to JavaScript

  28. 28

    pass value from object to another object in javascript

  29. 29

    Is there another way to pass an object to a function?

HotTag

Archive