vendredi 30 juillet 2021

How to filter list data by id and show the single object in HTML template by django?

This is the Json List Below:

"chartOfAccounts": [
            {
                "id": 147,
                "name": "Sales Product - Wholesale test",
                "description": "Sales - Wholesale",
                "balance": "0.00",
                "is_active": true,
                "is_editable": true,
                "account_detail_type": {
                    "id": 5,
                    "name": "Accounts Receivable (A/R)",
                    "account_type": {
                        "id": 2,
                        "name": "Accounts Receivable (A/R)",
                        "principle": {
                            "id": 1,
                            "name": "Asset",
                            "calculation_type": "dr"
                        }
                    },
                    "calculation_type": "dr"
                }
            },
            {
                "id": 146,
                "name": "Sales Product - Wholesale test",
                "description": "Sales - Wholesale",
                "balance": "0.00",
                "is_active": true,
                "is_editable": true,
                "account_detail_type": {
                    "id": 5,
                    "name": "Accounts Receivable (A/R)",
                    "account_type": {
                        "id": 2,
                        "name": "Accounts Receivable (A/R)",
                        "principle": {
                            "id": 1,
                            "name": "Asset",
                            "calculation_type": "dr"
                        }
                    },
                    "calculation_type": "dr"
                }
            },
            {
                "id": 145,
                "name": "Cash in hand rony",
                "description": "Cash in hand rony",
                "balance": "-45980.00",
                "is_active": true,
                "is_editable": true,
                "account_detail_type": {
                    "id": 1,
                    "name": "Cash and cash equivalents",
                    "account_type": {
                        "id": 1,
                        "name": "Cash and cash equivalents",
                        "principle": {
                            "id": 1,
                            "name": "Asset",
                            "calculation_type": "dr"
                        }
                    },
                    "calculation_type": "dr"
                }
            },
            {
                "id": 144,
                "name": "6yt4",
                "description": "gyyy",
                "balance": "5203.00",
                "is_active": true,
                "is_editable": true,
                "account_detail_type": {
                    "id": 1,
                    "name": "Cash and cash equivalents",
                    "account_type": {
                        "id": 1,
                        "name": "Cash and cash equivalents",
                        "principle": {
                            "id": 1,
                            "name": "Asset",
                            "calculation_type": "dr"
                        }
                    },
                    "calculation_type": "dr"
                }
            },
            {
                "id": 99,
                "name": "Cash in hand Monim",
                "description": "monim cash",
                "balance": "-1759.00",
                "is_active": true,
                "is_editable": true,
                "account_detail_type": {
                    "id": 1,
                    "name": "Cash and cash equivalents",
                    "account_type": {
                        "id": 1,
                        "name": "Cash and cash equivalents",
                        "principle": {
                            "id": 1,
                            "name": "Asset",
                            "calculation_type": "dr"
                        }
                    },
                    "calculation_type": "dr"
                }
            },
            {
                "id": 98,
                "name": "Monim Capital",
                "description": "Monim Capital",
                "balance": "50000.00",
                "is_active": true,
                "is_editable": true,
                "account_detail_type": {
                    "id": 10,
                    "name": "Owen's Capital",
                    "account_type": {
                        "id": 6,
                        "name": "Owen's Capital",
                        "principle": {
                            "id": 3,
                            "name": "Owen's Equity",
                            "calculation_type": "cr"
                        }
                    },
                    "calculation_type": "cr"
                }
            },
            {
                "id": 93,
                "name": "Payroll - m@m.bn",
                "description": "Payroll - m@m.bn",
                "balance": "0.00",
                "is_active": true,
                "is_editable": false,
                "account_detail_type": {
                    "id": 12,
                    "name": "Expenses",
                    "account_type": {
                        "id": 7,
                        "name": "Revenue",
                        "principle": {
                            "id": 3,
                            "name": "Owen's Equity",
                            "calculation_type": "cr"
                        }
                    },
                    "calculation_type": "dr"
                }
            },
            {
                "id": 12,
                "name": "Profit",
                "description": "Profit",
                "balance": "437690.75",
                "is_active": true,
                "is_editable": false,
                "account_detail_type": {
                    "id": 11,
                    "name": "Income",
                    "account_type": {
                        "id": 7,
                        "name": "Revenue",
                        "principle": {
                            "id": 3,
                            "name": "Owen's Equity",
                            "calculation_type": "cr"
                        }
                    },
                    "calculation_type": "cr"
                }
            },
            {
                "id": 10,
                "name": "Rajib",
                "description": "Test",
                "balance": "50000.00",
                "is_active": true,
                "is_editable": false,
                "account_detail_type": {
                    "id": 11,
                    "name": "Income",
                    "account_type": {
                        "id": 7,
                        "name": "Revenue",
                        "principle": {
                            "id": 3,
                            "name": "Owen's Equity",
                            "calculation_type": "cr"
                        }
                    },
                    "calculation_type": "cr"
                }
            },
            {
                "id": 9,
                "name": "Sales - Product",
                "description": "Sales - Product",
                "balance": "0.00",
                "is_active": true,
                "is_editable": false,
                "account_detail_type": {
                    "id": 11,
                    "name": "Income",
                    "account_type": {
                        "id": 7,
                        "name": "Revenue",
                        "principle": {
                            "id": 3,
                            "name": "Owen's Equity",
                            "calculation_type": "cr"
                        }
                    },
                    "calculation_type": "cr"
                }
            },
            {
                "id": 8,
                "name": "Purchases - Product",
                "description": "Purchases - Product",
                "balance": "47388.00",
                "is_active": true,
                "is_editable": false,
                "account_detail_type": {
                    "id": 12,
                    "name": "Expenses",
                    "account_type": {
                        "id": 7,
                        "name": "Revenue",
                        "principle": {
                            "id": 3,
                            "name": "Owen's Equity",
                            "calculation_type": "cr"
                        }
                    },
                    "calculation_type": "dr"
                }
            },
            {
                "id": 7,
                "name": "Payroll Expenses",
                "description": "Payroll Expenses",
                "balance": "0.00",
                "is_active": true,
                "is_editable": false,
                "account_detail_type": {
                    "id": 12,
                    "name": "Expenses",
                    "account_type": {
                        "id": 7,
                        "name": "Revenue",
                        "principle": {
                            "id": 3,
                            "name": "Owen's Equity",
                            "calculation_type": "cr"
                        }
                    },
                    "calculation_type": "dr"
                }
            },
            {
                "id": 6,
                "name": "Office expenses",
                "description": "Office expenses",
                "balance": "28899.00",
                "is_active": true,
                "is_editable": false,
                "account_detail_type": {
                    "id": 12,
                    "name": "Expenses",
                    "account_type": {
                        "id": 7,
                        "name": "Revenue",
                        "principle": {
                            "id": 3,
                            "name": "Owen's Equity",
                            "calculation_type": "cr"
                        }
                    },
                    "calculation_type": "dr"
                }
            },
            {
                "id": 5,
                "name": "Accounts Payable (A/P)",
                "description": "Accounts Payable (A/P)",
                "balance": "18491.00",
                "is_active": true,
                "is_editable": false,
                "account_detail_type": {
                    "id": 9,
                    "name": "Accounts Payable (A/P)",
                    "account_type": {
                        "id": 5,
                        "name": "Current liabilities",
                        "principle": {
                            "id": 2,
                            "name": "Liability",
                            "calculation_type": "cr"
                        }
                    },
                    "calculation_type": "cr"
                }
            },
            {
                "id": 4,
                "name": "Inventory",
                "description": "Inventory",
                "balance": "88682.75",
                "is_active": true,
                "is_editable": false,
                "account_detail_type": {
                    "id": 7,
                    "name": "Inventory",
                    "account_type": {
                        "id": 3,
                        "name": "Current assets",
                        "principle": {
                            "id": 1,
                            "name": "Asset",
                            "calculation_type": "dr"
                        }
                    },
                    "calculation_type": "dr"
                }
            },
            {
                "id": 3,
                "name": "Accounts Receivable (A/R)",
                "description": "Accounts Receivable (A/R)",
                "balance": "2500.00",
                "is_active": true,
                "is_editable": false,
                "account_detail_type": {
                    "id": 5,
                    "name": "Accounts Receivable (A/R)",
                    "account_type": {
                        "id": 2,
                        "name": "Accounts Receivable (A/R)",
                        "principle": {
                            "id": 1,
                            "name": "Asset",
                            "calculation_type": "dr"
                        }
                    },
                    "calculation_type": "dr"
                }
            },
            {
                "id": 1,
                "name": "Rajib",
                "description": "Test",
                "balance": "431248.00",
                "is_active": true,
                "is_editable": false,
                "account_detail_type": {
                    "id": 1,
                    "name": "Cash and cash equivalents",
                    "account_type": {
                        "id": 1,
                        "name": "Cash and cash equivalents",
                        "principle": {
                            "id": 1,
                            "name": "Asset",
                            "calculation_type": "dr"
                        }
                    },
                    "calculation_type": "dr"
                }
            }
        ],

From this JSON list data I want to filter it by id and show it on an html template! Basically this needs for a edit tasks. when someone click on edit button particular id is passed. like.. when id is 147 I want to print 147's other data like name, description, balance, account details type! And this will be like a single object.

See the belows HTML Format: Here I want to show the data like name, description, balance etc in the value template:

                                 <div class="form-group row">
                                    <label class="col-form-label col-md-2">Name</label>
                                    <div class="col-md-10">
                                        <input type="text" class="form-control" name="name"
                                               value="">
                                    </div>
                                </div>
                               <div class="form-group row">
                                    <label class="col-form-label col-md-2">Description</label>
                                    <div class="col-md-10">
                                        <input type="text" class="form-control" name="desc"
                                               value="">
                                    </div>
                                </div>
                              <div class="form-group row">
                                    <label class="col-form-label col-md-2">Balance</label>
                                    <div class="col-md-10">
                                        <input type="text" class="form-control" name="bal"
                                               value="">
                                    </div>
                                </div>



Aucun commentaire:

Enregistrer un commentaire