my init.py in django project
from pymodm.connection import connect, _get_db
from pymongo import MongoClient
client = MongoClient()
entity_record_clctn = client['platform_configuration'].entity_record_model
entity_clctn = client['platform_configuration'].entity_model
my tests.py in django project
from data_upload import client, entity_clctn, entity_record_clctn
class EntityRecordsTests(unittest.TestCase):
@classmethod
def setUpClass(cls):
print("setup")
global client
global entity_clctn
global entity_record_clctn
entity_record_clctn = client['test_database'].entity_record_model
entity_clctn = client['test_database'].entity_model
i am not able to change variables defined in init.py when these varibles are used in other files like views.py where i use them they point to the earlier values only can i do it? how?
this is my view.py
from data_upload import entity_clctn, entity_record_clctn
def get_entity_keys_by_name(name):
entity = entity_clctn.find_one({"name": name})
return [entity['entity_primary_key'], entity['entity_display_name']]
Aucun commentaire:
Enregistrer un commentaire