1
1
1thater2020-05-25 21:21:36
Django
1thater, 2020-05-25 21:21:36

How to get data from the database and generate JSON?

I apologize in advance for the confusion.

How the site works in my head:
the site goes down -> makes a request to the server -> the server returns a JSON file -> javascript works with this JSON and populates the site with certain data.
(through this JSON file, markers on the leaflet map will be drawn)

It is necessary that data be entered through the admin part, and then, through a database request, give a JSON file.

What is the best and easiest way to achieve what you want?

upd:
An example of JSON that the site should receive.

[
{
    "endPlace": [425, 330],
    "icon": "endIcon30",
    "startPlace": [
        {
            "startPoint": [45, 875],
            "icon": "startIcon20",
            "url": ["[email protected]", "3mcWTjoi2zFE"]
        }
    ]
},
{
  "endPlace": [452, 175],
  "icon": "endIcon30",
  "startPlace": [
      {
          "startPoint": [936, 845],
          "icon": "startIcon20",
          "url": ["[email protected]", "[email protected]"]
      }
  ]
},
{
  "endPlace": [10, 10],
  "icon": "endIcon30",
  "startPlace": [
      {
          "startPoint": [54, 845],
          "icon": "startIcon20",
          "url": ["_aC5423TjUU", "3mcWT345zFE"]
      }
  ]
}
]

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
szanislo, 2020-05-26
@1thater

you can use mongodb as a base

V
Vladimir Korotenko, 2020-05-25
@firedragon

make select
the results of this select convert to jison
on the client fill something based on this data
If something is missing, then repeat the steps

R
Rais, 2020-05-25
@0pauc0

A straight forward question.
- Why not store this data directly in json on the back?
Or are there too many of them?
If there are hundreds and thousands of records, then why bother with the database?
I read the json file into the dictionary, found what I needed with a simple search and gave it to the front.
Not?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question