E
E
Enter_a_nickname2022-02-01 21:13:04
Django
Enter_a_nickname, 2022-02-01 21:13:04

How to correctly write json structure in models.py of django project when working with MongoDB?

My project database is MongoDB, to connect mongo and django project (using version 4.0.1) I use "djОngo" engine. The database connection is working correctly.
I want to store data in MongoDB that is received from an external API or written through a form on a site page, which can have nested lists, or sometimes nested objects.
An example of a json structure that will be written through the form and come via the API:

"make": {
      "1_new": 21,
      "2_new": 16,
      "right": 80,
      "left": 10,
      },
   "static": [
      {
         "name": " 1",
         "number": 1,
         "id":93,
         "day": {
            "start": 7,
            "end": 23,
            "personal": false,
            "_on": false,
            "_off": false,
            "ors": [
               {"name": "камни",
                "number": 1,
                "status": true}


How can I write this structure in the models.py of the django project?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question