path = path + "/LogisWare/core/install/NIGERIA_STATES_AND_LGS.json" with open(path) as json_file: json_data = json.load(json_file) for data in json_data: print() state_name = data['state']['name'] print(state_name) try: State.objects.get(name=state_name) except Exception: state_model = State() state_model.name = state_name state_model.save() # try: # State.objects.get( name = state_name ) # except State.DoesNotExist: # state_model = State() # state_model.name = state_name # state_model.save() # state_locals = data['state']['locals'] # print("---------------") # for local in state_locals: # local_name = local['name'] # if LGA.objects.filter( name = local_name ).count() == 0: # print( local_name )
level = Level() level.code = 'PERAK' level.name = 'TAHAP PERAK' level.daily_task_count = 50 level.save() level = Level() level.code = 'GANGSA' level.name = 'TAHAP GANGSA' level.daily_task_count = 20 level.save() state = State() state.code = 'WP' state.name = 'WILAYAH PERSEKUTUAN' state.save() state = State() state.code = 'SL' state.name = 'SELANGOR' state.save() state = State() state.code = 'PK' state.name = 'PERAK' state.save() state = State() state.code = 'NS' state.name = 'NEGERI SEMBILAN'