Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Get json or dictionary type data from string data from legacy database
I am working on a website and I have a legacy database in which a field saved data like this 'a:76:{s:6:\"marque\";a:6:{s:4:\"name\";s:6:\"Marque\";s:5:\"value\";s:10:\"Volkswagen\";s:8:\"position\";s:1:\"0\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"0\";}s:6:\"modele\";a:6:{s:4:\"name\";s:7:\"Modèle\";s:5:\"value\";s:11:\"Confortline\";s:8:\"position\";s:1:\"1\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"0\";}s:7:\"version\";a:6:{s:4:\"name\";s:7:\"Version\";s:5:\"value\";s:10:\"California\";s:8:\"position\";s:1:\"2\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"0\";}s:7:\"chassis\";a:6:{s:4:\"name\";s:7:\"Chassis\";s:5:\"value\";s:2:\"T5\";s:8:\"position\";s:1:\"3\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"0\";}s:13:\"pa_surnom-van\";a:6:{s:4:\"name\";s:13:\"pa_surnom-van\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:1:\"4\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:12:\"pa_amenageur\";a:6:{s:4:\"name\";s:12:\"pa_amenageur\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:1:\"5\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:8:\"pa_annee\";a:6:{s:4:\"name\";s:8:\"pa_annee\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:1:\"6\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:14:\"pa_carte-grise\";a:6:{s:4:\"name\";s:14:\"pa_carte-grise\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:1:\"7\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:11:\"pa_couchage\";a:6:{s:4:\"name\";s:11:\"pa_couchage\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:1:\"9\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:17:\"pa_places-assises\";a:6:{s:4:\"name\";s:17:\"pa_places-assises\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"10\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:22:\"pa_mise-en-circulation\";a:6:{s:4:\"name\";s:22:\"pa_mise-en-circulation\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"11\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:15:\"pa_motorisation\";a:6:{s:4:\"name\";s:15:\"pa_motorisation\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"12\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:19:\"pa_4-roues-motrices\";a:6:{s:4:\"name\";s:19:\"pa_4-roues-motrices\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"13\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:12:\"pa_carburant\";a:6:{s:4:\"name\";s:12:\"pa_carburant\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"14\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:23:\"pa_consommation-moyenne\";a:6:{s:4:\"name\";s:23:\"pa_consommation-moyenne\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"15\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:14:\"pa_amenagement\";a:6:{s:4:\"name\";s:14:\"pa_amenagement\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"16\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:14:\"pa_kilometrage\";a:6:{s:4:\"name\";s:14:\"pa_kilometrage\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"17\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:19:\"pa_boite-de-vitesse\";a:6:{s:4:\"name\";s:19:\"pa_boite-de-vitesse\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"18\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:13:\"pa_type-boite\";a:6:{s:4:\"name\";s:13:\"pa_type-boite\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"19\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:24:\"pa_regulateur-de-vitesse\";a:6:{s:4:\"name\";s:24:\"pa_regulateur-de-vitesse\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"20\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:22:\"pa_limiteur-de-vitesse\";a:6:{s:4:\"name\";s:22:\"pa_limiteur-de-vitesse\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"21\";s:10:\"is_visible\";s:1:\"0\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:21:\"pa_controle-technique\";a:6:{s:4:\"name\";s:21:\"pa_controle-technique\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"23\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:6:\"pa_ebv\";a:6:{s:4:\"name\";s:6:\"pa_ebv\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"24\";s:10:\"is_visible\";s:1:\"0\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:6:\"pa_eds\";a:6:{s:4:\"name\";s:6:\"pa_eds\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"25\";s:10:\"is_visible\";s:1:\"0\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:27:\"pa_indicateur-pression-pneu\";a:6:{s:4:\"name\";s:27:\"pa_indicateur-pression-pneu\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"26\";s:10:\"is_visible\";s:1:\"0\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:6:\"pa_abs\";a:6:{s:4:\"name\";s:6:\"pa_abs\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"27\";s:10:\"is_visible\";s:1:\"0\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:16:\"pa_climatisation\";a:6:{s:4:\"name\";s:16:\"pa_climatisation\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"29\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:24:\"pa_fermeture-centralisee\";a:6:{s:4:\"name\";s:24:\"pa_fermeture-centralisee\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"30\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:21:\"pa_type-climatisation\";a:6:{s:4:\"name\";s:21:\"pa_type-climatisation\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"31\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:23:\"pa_siege-avant-pivotant\";a:6:{s:4:\"name\";s:23:\"pa_siege-avant-pivotant\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"32\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:24:\"pa_siege-avant-chauffant\";a:6:{s:4:\"name\";s:24:\"pa_siege-avant-chauffant\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"33\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:17:\"pa_toit-relevable\";a:6:{s:4:\"name\";s:17:\"pa_toit-relevable\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"34\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:11:\"pa_attelage\";a:6:{s:4:\"name\";s:11:\"pa_attelage\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"35\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:6:\"pa_gps\";a:6:{s:4:\"name\";s:6:\"pa_gps\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"36\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:13:\"pa_lecteur-cd\";a:6:{s:4:\"name\";s:13:\"pa_lecteur-cd\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"37\";s:10:\"is_visible\";s:1:\"0\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:25:\"pa_convertisseur-12v-220v\";a:6:{s:4:\"name\";s:25:\"pa_convertisseur-12v-220v\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"39\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:25:\"pa_chauffage-stationnaire\";a:6:{s:4:\"name\";s:25:\"pa_chauffage-stationnaire\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"40\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:16:\"pa_store-lateral\";a:6:{s:4:\"name\";s:16:\"pa_store-lateral\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"41\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:14:\"pa_store-hayon\";a:6:{s:4:\"name\";s:14:\"pa_store-hayon\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"42\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:13:\"pa_porte-velo\";a:6:{s:4:\"name\";s:13:\"pa_porte-velo\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"43\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:14:\"pa_radar-recul\";a:6:{s:4:\"name\";s:14:\"pa_radar-recul\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"44\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:15:\"pa_camera-recul\";a:6:{s:4:\"name\";s:15:\"pa_camera-recul\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"45\";s:10:\"is_visible\";s:1:\"0\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:20:\"pa_douche-exterieure\";a:6:{s:4:\"name\";s:20:\"pa_douche-exterieure\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"46\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:21:\"pa_rallonge-electique\";a:6:{s:4:\"name\";s:21:\"pa_rallonge-electique\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"47\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:8:\"pa_evier\";a:6:{s:4:\"name\";s:8:\"pa_evier\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"48\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:21:\"pa_plaque-cuisson-gaz\";a:6:{s:4:\"name\";s:21:\"pa_plaque-cuisson-gaz\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"49\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:16:\"pa_refrigerateur\";a:6:{s:4:\"name\";s:16:\"pa_refrigerateur\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"50\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:11:\"pa_penderie\";a:6:{s:4:\"name\";s:11:\"pa_penderie\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"51\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:25:\"pa_plan-travail-interieur\";a:6:{s:4:\"name\";s:25:\"pa_plan-travail-interieur\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"52\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:21:\"pa_occultation-sejour\";a:6:{s:4:\"name\";s:21:\"pa_occultation-sejour\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"53\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:21:\"pa_occultation-cabine\";a:6:{s:4:\"name\";s:21:\"pa_occultation-cabine\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"54\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:20:\"pa_banquette-lit-bas\";a:6:{s:4:\"name\";s:20:\"pa_banquette-lit-bas\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"55\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:11:\"pa_lit-haut\";a:6:{s:4:\"name\";s:11:\"pa_lit-haut\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"56\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:19:\"pa_table-exterieure\";a:6:{s:4:\"name\";s:19:\"pa_table-exterieure\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"58\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:10:\"pa_chaises\";a:6:{s:4:\"name\";s:10:\"pa_chaises\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"59\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:14:\"pa_set-cuisine\";a:6:{s:4:\"name\";s:14:\"pa_set-cuisine\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"60\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:17:\"pa_douche-solaire\";a:6:{s:4:\"name\";s:17:\"pa_douche-solaire\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"62\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:14:\"pa_coffre-fort\";a:6:{s:4:\"name\";s:14:\"pa_coffre-fort\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"63\";s:10:\"is_visible\";s:1:\"0\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:21:\"pa_reserve-eau-propre\";a:6:{s:4:\"name\";s:21:\"pa_reserve-eau-propre\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"66\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:19:\"pa_reserve-eau-sale\";a:6:{s:4:\"name\";s:19:\"pa_reserve-eau-sale\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"67\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:17:\"pa_toilette-seche\";a:6:{s:4:\"name\";s:17:\"pa_toilette-seche\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"68\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:13:\"pa_complement\";a:6:{s:4:\"name\";s:13:\"pa_complement\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"72\";s:10:\"is_visible\";s:1:\"0\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:19:\"equipement-securite\";a:6:{s:4:\"name\";s:20:\"Equipement securité\";s:5:\"value\";s:271:\"RŽgulateur de vitesse, limitateur de vitesse, assitance sationnement, attache Isofix bŽbŽ, correcteur trajectoire(EDS), antiblocage roues(ABS), rŽpartiteur Žlectronique freinage(EBV), indicateur pression pneu, fermeture centralisŽe, radal de recul, camŽra de recul\";s:8:\"position\";s:2:\"73\";s:10:\"is_visible\";s:1:\"0\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"0\";}s:18:\"equipement-confort\";a:6:{s:4:\"name\";s:18:\"Equipement confort\";s:5:\"value\";s:95:\"climatisation, triptonic 3 zones,GPS,lecteur CD, attelage, port USB, pneu hiver, chaines neiges\";s:8:\"position\";s:2:\"74\";s:10:\"is_visible\";s:1:\"0\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"0\";}s:10:\"pa_version\";a:6:{s:4:\"name\";s:10:\"pa_version\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"74\";s:10:\"is_visible\";s:1:\"0\";s:12:\"is_variation\";s:1:\"0\";s:11:\"is_taxonomy\";s:1:\"1\";}s:21:\"equipement-specifique\";a:6:{s:4:\"name\";s:22:\"Equipement spécifique\";s:5:\"value\";s:569:\"sige avant pivotant, sige avant chauffant, chauffage stationnaire, tŽlŽcommande, toit relevable manuel, store latŽral, store hayon, coffre fort, porte vŽlo(2), douche extrieure, convertisseur 12V/220, rallonge electrique, bloc Žvier, penderie, plaque cuissson, rŽfrigŽrateur, coffre rangement, plan de travail intrieur, occultation sŽjour, occultation cabien, sur matelas confort, insolite inside, Iso Top lit haut, multi-poches rangement, moustiquaire porte coulissante, moustiquaire fentre, moustiquaire hayon, rŽserve eau propre, rŽserve eau sale\";s:8:\"position\";s:2:\"75\";s:10:\"is_visible\";s:1:\"0\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"0\";}s:10:\"pa_chassis\";a:6:{s:4:\"name\";s:10:\"pa_chassis\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"75\";s:10:\"is_visible\";s:1:\"0\";s:12:\"is_variation\";s:1:\"0\";s:11:\"is_taxonomy\";s:1:\"1\";}s:9:\"pa_modele\";a:6:{s:4:\"name\";s:9:\"pa_modele\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"76\";s:10:\"is_visible\";s:1:\"0\";s:12:\"is_variation\";s:1:\"0\";s:11:\"is_taxonomy\";s:1:\"1\";}s:11:\"accessoires\";a:6:{s:4:\"name\";s:11:\"Accessoires\";s:5:\"value\";s:122:\"vaisselles (4), set cuisine, cafetire, douche solaire, toilette sche, bbq extrieur, table extrieure, sige enfant\";s:8:\"position\";s:2:\"76\";s:10:\"is_visible\";s:1:\"0\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"0\";}s:8:\"services\";a:6:{s:4:\"name\";s:8:\"Services\";s:5:\"value\";s:181:\"stationnement votre vŽhicule dans iun lieu privatif sŽcurisŽ, possibilitŽ de dŽpart depuis gare/aŽroport leplus proche, kit linge de maison, kit nettoyage, accepte les animaux\";s:8:\"position\";s:2:\"77\";s:10:\"is_visible\";s:1:\"0\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"0\";}s:9:\"pa_region\";a:6:{s:4:\"name\";s:9:\"pa_region\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"78\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:8:\"pa_ville\";a:6:{s:4:\"name\";s:8:\"pa_ville\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"79\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:12:\"pa_lattitude\";a:6:{s:4:\"name\";s:12:\"pa_lattitude\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"80\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:12:\"pa_longitude\";a:6:{s:4:\"name\";s:12:\"pa_longitude\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"81\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:14:\"pa_code-postal\";a:6:{s:4:\"name\";s:14:\"pa_code-postal\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"82\";s:10:\"is_visible\";s:1:\"1\";s:12:\"is_variation\";s:1:\"1\";s:11:\"is_taxonomy\";s:1:\"1\";}s:9:\"pa_marque\";a:6:{s:4:\"name\";s:9:\"pa_marque\";s:5:\"value\";s:0:\"\";s:8:\"position\";s:2:\"84\";s:10:\"is_visible\";s:1:\"0\";s:12:\"is_variation\";s:1:\"0\";s:11:\"is_taxonomy\";s:1:\"1\";}}' I want this data into json or disctionary or list format to save in DB. I have tried json (loads and dumps), pickel (loads and dumps), removed backslash from string data. but nothing worked. My … -
Is there any way to make a json response out of a list
I am trying to convert a list response to JSON object. The response I am getting is: "", "Worldwide", "2460815269", 0, "https://www.linkedin.com/jobs/view/recruiter-at-google-2460815269?refId=d9d72fd7-1db0-4ff0-acab-03ead732e153&trackingId=6fp28iXCEmemhFiPSxBOmQ%3D%3D&position=1&pageNum=0&trk=public_jobs_job-result-card_result-card_full-click", "https://www.linkedin.com/jobs/view/externalApply/2460815269?url=https%3A%2F%2Fcareers%2Egoogle%2Ecom%2Fjobs%2Fresults%2F97443853348283078-recruiter%2F%3Fsrc%3DOnline%252FLinkedIn%252Flinkedin_us%26utm_source%3Dlinkedin%26utm_medium%3Djobposting%26utm_campaign%3Dcontract&urlHash=xVB_&refId=d9d72fd7-1db0-4ff0-acab-03ead732e153&trackingId=6fp28iXCEmemhFiPSxBOmQ%3D%3D&trk=public_jobs_apply-link-offsite", "Recruiter", "Google", "Atlanta, GA", "Note: By applying to this position your application is automatically submitted to the following locations: Austin, TX, USA; Atlanta, GA, USA; Chicago, IL, USA; Los Angeles, CA, USA; Mountain View, CA, USA; New York, NY, USA; Seattle, WA, USA; San Francisco, CA, USA; Washington, DC, USA; Bellevue, WA, USA; Ann Arbor, MI, USA; Durham, NC, USA; Boulder, CO, USA\n\nMinimum qualifications:\n\nBachelor's degree or equivalent practical experience.\n2 years of full-cycle recruiting experience in an agency or corporate setting\n\n\n\nPreferred qualifications:\n\n3 years of experience recruiting for technical and/or non-technical profiles in an agency or corporate setting\nExperience closing senior level candidates and negotiating complex compensation packages leveraging experience with competing for top tech talent\nSolid history of solving complex problems and delivering significant impact as an individual contributor. A track record of personal accountability, strong work ethic, integrity, and proven organizational skills with attention to detail\nAbility to handle customer relationship management, provide strong consultative skills, and work in a large-team environment\nExcellent communication and interpersonal skills. Proven ability to take initiative and build strong, productive relationships\n\n\n\nAbout the job\nGoogle's known for … -
How to integrate bootstrap on django locally?
https://colorlib.com/wp/template/login-form-v14/ This is where I downloaded the template package from but my issues is that when I run python manage.py. The page wont show anything but If I click on the html file it displays the template perfectly. I've already copied the CDN andlinked the files on the HTML files. -
How to set the default schema when querying PostgreSQL database with SqlAlchemy django-postgrespool2 QueuePool?
Context / environment Using a SqlAlchemy django-postgrespool2 connection pool to query a PostgreSQL database. I'm building a Python Django backend. What I'm tryihg to achieve When I query a table, I want to provide a default schema so I don't have to explicitly type it for every table I query. Problem For example, now I have to write schema.table for every table I query the following way: def poolTest(): dbpool = DbPool() sql = "SELECT * FROM mbraindb.sysproductfamilies" sqlParams = () result = dbpool.execute(sql, sqlParams) As you can see, I have to type mbraindb.sysproductfamilies but I want to provide mbraindb in the code so the query can be written like SELECT * FROM sysproductfamilies. For example with psycopg2 I can provide the default schema mbraindb the following way: self.connection = psycopg2.connect( host=settings.DATABASES["default"]["HOST"], port=settings.DATABASES["default"]["PORT"], user=settings.DATABASES["default"]["USER"], password=settings.DATABASES["default"]["PASSWORD"], database=self.database, options=f'-c search_path={self.schema}', cursor_factory=psycopg2.extras.RealDictCursor) But I don't know how to achieve it with the SqlAlchemy django-postgrespool2 QueuePool setup. See my code below. Code My current DbPool helper class which sets up the SqlAlchemy pool (used in the poolTest example above): import psycopg2 from sqlalchemy import create_engine import traceback from mbrain import settings from dataClasses.EmptyObject import * import json import sqlalchemy.pool as pool from sqlalchemy.pool import … -
Django Template Queryset Execution, is the Data Stored in the Server's Memory?
My question revolves around the memory usage of the Django App and I am making an assumption that once the template is loaded, the view's references to objects (memory) are queued for garbage collection at some point. If I am executing a Queryset within the Django Template, does the Server store that result in memory? -
Django Annotate A Related Object That Is Several Objects Deep In Relation
I am in the process of building a budget/finance tracking app using Python/Django. I am trying to figure out how to annotate some objects that are several objects deep in relation. I am trying to annotate my "ExpenseBudgetItem" objects to include the total amount of transactions and total amount spent so I can display it on my budget page. My problem is that I can't figure out how to accomplish this. Below is a snippet of my models.py file and below that is what I have tried. # models.py class BudgetPeriod(models.Model): # A month to represent a budget period month = models.IntegerField(choices=CHOICES, default=datetime.today().month) year = models.PositiveIntegerField(default=datetime.today().year) # Expense Models class ExpenseCategory(models.Model): # Ex: Entertainment can be an expense category budget_period = models.ForeignKey('BudgetPeriod', on_delete=models.CASCADE, related_name='expense_categories') name = models.CharField(max_length=50) class ExpenseBudgetItem(models.Model): # Ex: Golf, movies, games can be budget items of entertainment expense_category = models.ForeignKey('ExpenseCategory', on_delete=models.CASCADE, related_name='expense_budget_items') name = models.CharField(max_length=50) planned_amount = models.DecimalField(max_digits=9, decimal_places=2) class ExpenseTransaction(models.Model): # Ex: All of my expense transactions for each of those budget items expense_budget_item = models.ForeignKey('ExpenseBudgetItem', on_delete=models.CASCADE, related_name='expense_transactions') name = models.CharField(max_length=50) amount = models.DecimalField(max_digits=9, decimal_places=2) # Income Models - Note: I did not make an income category model like I did for expenses class IncomeBudgetItem(models.Model): # … -
how to implement Oauth authentication for Linkedin with Django
I am facing difficulty in adding Linkedin login with OAuth Authentication with django. If anyone has faced the same problem please share. -
Sending email from same domain, but non existent user name with google SMTP
I want to be able to send an email from a random user address, that uses my domain. So for example: random1234akdh@mydomain.com. I'm using google as my email provider, and from what i can tell when using smtp it requires authentication for an existing account. Is there any way to create this spoof email temporarily? -
How to run Celery tasks on model creation in Django
In Laravel, we have an Observer pattern which observes events on create and on update of the given model, having some dirty fields on it. It allows to run jobs asynchronously on some events in the database table. In Django, how would we use the combination of django and celery to achieve the same goal? For example, I want to change the table row after it was created asynchronously. -
Django , get following list and followers list of a particular user
Created a UserProfile model with a through M2M field. class UserProfile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE, default=None , null= True) relationships = models.ManyToManyField('self', through='Relationship', symmetrical=False, ) In the through model, is the Relationship table which has the foreign keys of UserProfile who are related to each other on a follower, following relationship. class Relationship(models.Model): from_person = models.ForeignKey(UserProfile,on_delete=models.CASCADE,related_name='from_people') to_person = models.ForeignKey(UserProfile,on_delete=models.CASCADE,related_name='to_people') so basically, if UserA wanted to create a relationship between himself and another userB, it'll be a simple addition like; Relationship.objects.get_or_create( from_person=UserA, to_person= UserB) There are two foreign keys in the relationship model relating to each other. Now when I have a UserProfile instance, which query is appropriate to determine the users UserProfile is following? I am guessing I have to use filter() and include an argument to determine from_person = selfor something similar but can't seem to wrap my head around it. Below are methods under UserProfile #Get relationships def get_relationships(self): return self.relationships.all() #Get followers def get_related_to(self): return self.related_to.all() -
Dynamic dictionary keys in DJango table
I am absolutely new to Django need help. I have a dynamic list of dictionaries which I want to display in django table. [{'index': 'Price', 'Price': 1.0}, {'index': 'Sale', 'Price': 1.0}, {'index': 'Reviews', 'Price': -1.0}] "index" key will remain constant but second key is dynamic. I want to show this data in a table. I can show the value of first key but cant figure out how to show the value of dynamic key. My django template code is as below <div class="container fluid"> <table class="table table-striped"> <h2 class="text-center">Correlation with {{var}}</u></h2><br> <thead> <tr> <th>Index</th> <th>Score</th> </tr> {% for var in variable %} <tr> <td>{{var.index}}</td> <td>{{var.{{input}}</td> </tr> {% endfor %} </thead> </tbable> </div> Views.py def corelation(request): if request.method == "POST": var_input = request.POST.get('variable') data = {'Price':[23, 65], 'Sale':[76, 82], 'Reviews':[52, 34]} df = pd.dataframe(data) corr = df.corr() var_corr = corr[var_input].sort_values(ascending = False) #this is for showing item wise correlation() fucntion json_varCorr = var_corr.reset_index().to_json(orient ='records') data_varCorr = [] data_varCorr = json.loads(json_varCorr) context = {'variable': data_varCorr, 'input':var_input, } return render(request, 'variable.html', context) -
Is offline Django app is a good alternation for desktop app?
The task: Build an offline app to store and manage internal documents. The app has a features to sync between machines. My question: Should I go for an offline django app or a desktop app? Since, the stored documents needs to be in high level of privacy. Thank you! -
Getting logged out after logging in
I'm currently developing a Django web app, however I have an issue: After login, the user clicks on any button eg. Home (which has been linked to views with the @login_required decorator) and gets logged out and redirected back to the login page. I'm using Firebase for the authentication. My views.py: def postsign(request): email=request.POST.get('email') passw=request.POST.get('pass') try: user=auth.sign_in_with_email_and_password(email,passw) except: message="Invalid credentials. Try again." return render(request,"login.html", {"msg":message}) session_id=user['idToken'] request.session['uid']=str(session_id) return render(request,"pick.html") @login_required(login_url='login') def pick(request): return render_to_response('pick.html') My pick.html: {% load staticfiles %} <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta name="description" content=""> <meta name="author" content=""> <title>FYP - Is Your Network Safe?</title> <!-- Bootstrap core CSS --> <link href="{% static 'vendor/bootstrap/css/bootstrap.min.css' %}" rel="stylesheet"> <link href="{% static 'vendor/bootstrap/css/loader.css' %}" rel="stylesheet"> <!-- Custom fonts for this template --> <link href="{% static 'vendor/fontawesome-free/css/all.min.css' %}" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Varela+Round" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i" rel="stylesheet"> <!-- Custom styles for this template --> <link href="{% static 'css/grayscale.min.css' %}" rel="stylesheet"> <script src="https://api.mapbox.com/mapbox-gl-js/v1.11.1/mapbox-gl.js"></script> <link href="https://api.mapbox.com/mapbox-gl-js/v1.11.1/mapbox-gl.css" rel="stylesheet" /> </head> <body id="page-top"> <!-- Navigation --> <nav class="navbar navbar-expand-lg navbar-light fixed-top" id="mainNav"> <div class="container"> <a class="navbar-brand js-scroll-trigger" href="#page-top">TestPage</a> <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation"> Menu <i class="fas fa-bars"></i> </button> <div class="collapse navbar-collapse" id="navbarResponsive"> <ul class="navbar-nav ml-auto"> <li … -
Post method not allowed on Django Rest Framework
I'm working on a small project using Django Rest Framework and VueJS, i have a small bug after sending my POST request i get 405 POST Method Not Allowed, i don't know why since my request url is /contact/create/ This is my code : class ContactView(viewsets.ViewSet): def create(self, request): serializeObject = ContactSerializer(data = request.data) if serializeObject.is_valid(): serializeObject.save() contactObject = Contact.objects.all() contactSerializer = ContactSerializer(contactObject, many=True) return Response(contactSerializer.data, status = status.HTTP_201_CREATED) return Response(serializeObject.errors, status.HTTP_400_BAD_REQUEST) -
How to convert blob url into mp3 audio in django
So I'm working with recording audio from browser for which it is using Mic recorder API, now this Api after recording returns a blob url which I send to my project's django backend but the problem is how to get that audio file back from blob url at backend? For your reference this is how it generate blob url: const Mp3Recorder = new MicRecorder({ bitRate: 128 }); stop = () => { Mp3Recorder.stop() .getMp3() .then(([buffer, blob]) => { const blobURL = URL.createObjectURL(blob); console.log(blobURL); this.setState({ blobURL, isRecording: false }); this.sendAudioFile(blobURL); }) .catch((e) => console.log(e)); }; and this is code for sending blob url to django backend sendAudioFile = (url) => { let data = new FormData(); data.append("file", url); return axios .post("http://localhost:8000/recordings/", data, { headers: { "Content-Type": "multipart/form-data", }, }) .then((res) => { console.log(res); return res; }); Pls suggest a good solution as I've already gone through various stackoverflow answers for similar questions but the problem is not getting solved. -
Gunicorn not starting on AWS EB instance?
I am deploying a Django project onto an AWS EB instance. It runs perfectly locally. When I deploy through the CLI, it generates a Procfile that contains the command to start the gunicorn server. However, it is not getting started. I can SSH into the instance, run "python manage.py runserver" or run the line from the Procfile to start gunicorn, both start the server and get things working great. However, this should happen when the project is deployed, and it is not. I do not get any errors when making migrations, running the server, or manually starting gunicorn. So why is it not starting automatically? After deploying and going to the site, it gives a 502 error. -
Setting a cookie with samesite none on Django 2.2
I am trying to set a specific cookie to have samesite='None' for a Django project on version 2.2.x. I continue to get the below error. raise ValueError('samesite must be "lax" or "strict".') which I can see is coming from venv/lib/python3.9/site-packages/django/http/response.py if samesite: if samesite.lower() not in ('lax', 'strict'): raise ValueError('samesite must be "lax" or "strict".') self.cookies[key]['samesite'] = samesite I have tried to following: Set this globally in settings eg CSRF_COOKIE_SAMESITE = 'None', SESSION_COOKIE_SAMESITE = 'None' Setting this on the cookie that need it via set_cookie(name, value=value, secure=True, samesite='None') Both approaches don't work. I have also tried to installed the package django-cookies-samesite and adding its middleware, however it doesn't seem to make a difference. # example MIDDLEWARE = ( "django_cookies_samesite.middleware.CookiesSameSite", # other middleware ) When I set the value to None instead of 'None' no value is added and I believe Chrome falls back to lax when there isn't a value there. Is there a way around this? I can see the newer versions of Django support this however doing that upgrade for this project isn't possible at the moment. -
How to make views method accept images from form in Django?
I am trying to create objects in the database and store images user uploaded to the form. This form creates a items with an image and saves. My question is how to write the method so that it knows how to handle the image that was uploaded? This is just for development so I am not hosting to AWS but simply storing Images locally. Note: I am also creating my form the old fashion way and not creating a form.py file. >This is the error im getting: MultiValueDictKeyError at /createWish 'photos' => image = request.POST['photos'],>[enter image description here][1] **Views.py** def createItem(request): print(request.POST) validationErrors = Item.objects.validateItem(request.POST) if len(validationErrors) > 0: for key,value in validationErrors.items(): message.error(request, value) return redirect('wishes/add') loggedInUser = User.objects.get(id = request.session['loggedInID']) newItem = Item.objects.create( name = request.POST['itemName'], uploader = loggedInUser, image = request.POST['photos'], description = request.POST['desc'] ) return redirect('/home') **addItem.html** <form class="col-lg-8 offset-lg-2 " action="/createWish" method="POST" enctype="multipart/form-data"> {% csrf_token %} <div class="row justify-content-center"> <input class="form-control form-control-lg mb-5" type="text" name="itemName" placeholder="Add Items here..."> <input class="form-control form-control-lg mb-5" type="text" name="desc" placeholder="Add short description here..."> <input type="file" class="form-control-file mb-5" name="photos" id="exampleFormControlFile1"> <span class="input-group-btn mb-5"> <button class="btn btn-primary">Add Item</button> </span> </div> </form> -
django-rest-framework-simplejwt override CustomTokenObtainPairView add get() endpoint
I've modified the CustomTokenObtainPairView class to make use of external authorization (via an Oauth provider). Now, the login endpoint which I overrided to this: re_path(r'^api/oauth/$', views.user_views.token_obtain_pair, name='api-oauth'), works as intended when the request is a POST. The problem is the oauth provider sends a request to this endpoint but it's a GET. I need to make this view accept GET requests and do what it would normally do in a POST. I can't seem to find a way to do it. I've added a get method as this: class CustomTokenObtainPairView(TokenObtainPairView): serializer_class = CustomTokenObtainPairSerializer def get_serializer_class(self): return CustomTokenObtainPairSerializer def get(self, request, *args, **kwargs): return self.post(request, *args, **kwargs) but I still get a 405 Method Not Allowed error. How can I modify my view so that it also accepts get requests? -
django concatenate filter model
why this is not working? I can't concatenate the filter with another variable? I have a feeling that I'm being very dumb. I'm new at django and trying a couple of things with the model. When I use: birthdate__contains='-03-' works fine, but with the variable, nothing shows up at the url from django.shortcuts import render from .models import Employee from datetime import datetime # Create your views here. def index(request): currentMonth = datetime.now().month mes_atual = '-'+str(currentMonth)+'-' employees = Employee.objects.filter( birthdate__contains=mes_atual ) context = { 'employees' : employees } return render(request, 'index.html', context) thanks in advance -
Django m2m field custom queryset removing used options
I hope you can help me, I'm making an school app which have students, teachers, courses and groups that belong to a course. A course can have many groups with different students, no student can repeat on each group of the same course. To store students in group I use m2m field, but what I want is to show on m2m field queryset only the students that are active but not subscribed to the course, I achieved how to load that queryset but the problem is that even if I only select one student, all the students in the m2m field are related to the group instead of only the selected ones. I hope you can help me with that, let me show you what I'm doing: class Course(models.Model): name = models.CharField(verbose_name=_('Name'), max_length=100, blank=True, null=True) def get_all_groups(self): if self.usergroup_set.all(): return self.usergroup_set.all() return None def get_all_student_in_course(self): # Get all students in the course of each group students = None if self.get_all_groups(): for group in self.get_all_groups(): if students: students = students | group.get_students() # Combine all querysets in one else: students = group.get_students() # Setting initial queryset to combine return students def get_all_available_students(self): # Get all active students that are not taking … -
Django channels messaging app: Message not sending to websocket
I have completed this youtube tutorial (github link to code) on how to use channels and redis in Django(v. 3.1.7) to make an instant chat app. I did change a couple things from the tutorial, because he is on a different Django version. The error I get when I use his code is explained in this other stackoverflow post. I have messages saving to the database and I am successfully loading the 10 most recent messages on page load. But When I click the "send" button, I do not see the message show up in the list of messages (but it does save to the database). When I run redis-cli and type 'ping', I get 'PONG' in return so I think redis is working properly. When I click send, there are no javascript errors in the dev console and no python errors. It just does not show for me (or for a different logged in user who is in the same room). views.py: from django.shortcuts import render import json from django.contrib.auth.decorators import login_required from django.utils.safestring import mark_safe def index(request): return render(request, 'chat/index.html') @login_required def room(request, room_name): # OLD: WORKING (Mar 22, 6pm) return render(request, 'chat/room.html', { 'room_name': room_name }) routing.py: … -
Serializing the permissions objects of Permission Class in Django
I am writing a REST API to create Group and assign permissions to that group, for that I used GET method to get all the permissions available within using: permissions = Permission.objects.all() Now how do I serialize the list of objects in permissions so that I can get list of permissions in json and use it in frontend to assign the permissions while creating a group. Here is Snippet of code so far i have came Groupserializer class GroupSerializer(serializers.ModelSerializer): class Meta: model = Group fields = ('name','permissions') Views class UsersGroupCreateView(APIView): permission_classes = [IsAdminUser] def post(self , request , *args, **kwargs): serializer = GroupSerializer(data = request.data) if serializer.is_valid(): data = serializer.validated_data group = Group.objects.create(name = data.get('name')) return Response({"status":"Group Created"},status=status.HTTP_201_CREATED) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST class GetPerm(APIView): def get(self, request, *args, **kwargs): data = Permission.objects.all() permissions = PermissionSerializer(data = request.data) return Response({"list":"I WANT LIST OF PERMISSIONS"}) Any help would be appreciated !! -
Why is my app getting stuck on navigation
I have a route in my Angular app that is /service-categories. Here's the ngOnInit to the component that is loaded on that route: ngOnInit() { this.apiDataService.readData(env.routes.services.getServiceCategories, false, 'get').subscribe(response => { this.serviceCategories = response.data.map(serviceCategory => new ServiceCategory(serviceCategory)); }); } Here's the API view in Django REST Framework that gets those service categories: @api_view(['GET']) def service_categories(request): try: serviceCategories = ServiceCategory.objects.all() serializer = ServiceCategorySerializer(serviceCategories, many=True) return generic_data_response(serializer.data) except: return generic_internal_server_error_response() Everything works fine until I log in using Facebook. The route is /login and here is the code that handles that: this.socialAuthService.authState.pipe( switchMap((user: SocialUser) => { if (user && user.authToken) { this.socialUser = user; return this.authService.convertToken(user.provider.toLowerCase(), user.authToken) } else { return throwError(new Error('An unexpected error occurred.')); } }) ).subscribe((res) => { if (res.status === 200) { localStorage.setItem('__bn_api_current_user', JSON.stringify(this.socialUser)); localStorage.setItem('__bn_api_access', res.body.access_token); localStorage.setItem('__bn_api_refresh', res.body.refresh_token); this.router.navigate(['service-categories']); } }); localStorage is updated just fine but, upon navigating to service-categories, the application hangs. I can see the call to the API to get the service categories, and it goes into a pending state and just waits and waits until the app crashes. -
Django many to many autofilling user
I want to keep track of users that are associated with each team, but as soon as this code is executed every user in my database is added to my model. How do I avoid this? I have tried doing add() and remove() but none of them change the fact that every single user is stored in the database as soon as it loads. Thanks class Team(models.Model): name = models.CharField(max_length=120) abbreviation = models.CharField(max_length=3) id = models.IntegerField(primary_key=True) link = models.CharField(max_length=120) wins = models.IntegerField(default=0) losses = models.IntegerField(default=0) ties = models.IntegerField(default=0) points = models.IntegerField(default=0) users = models.ManyToManyField(User) def getTeams(): import requests baseUrl = "https://statsapi.web.nhl.com/" # INITALIZING THE DATA IN THE DATA DICTIONARY r = requests.get(baseUrl + '/api/v1/teams') originalData = r.json() # i dont need the copyright, only care about the teams originalData = originalData["teams"] for team in originalData: id = team["id"] try: databaseTeam = Team.objects.get(id = id) except Exception: Team.objects.create(id = id) databaseTeam = Team.objects.get(id = id) databaseTeam.name = team["name"] databaseTeam.abbreviation = team["abbreviation"] databaseTeam.link = team["link"] databaseTeam.save() print("done") @login_required def myTeamView(request): t1 = Thread(target=getTeams) t1.start() return(render(request, "teams/myTeams.html", {}))