python - JSON file reading by Django -


I have a JSON file the following format generated by Skrepi:

  [{ "Area_of_interest": [ "medicine"], "Department": [ "retail pharmacy: apothecary"], "duties": [ "education:"], "Job_function": [ "Texas health Presbyterian hospital Dallas a registered demand Working Pharmacy Technician hours in PRN Retail Pharmacy (as required) change the working days between the primary hours 9a-5p. Ega sometimes need the following 12 hours will be moved: ... "]," job_id ": [" 56345 "]," location "," "," Location "," "," Location "," "location "" "[" Texas health Dallas "]," transfer ": [" No. "]," change "" [ "Miscellaneous" ( "Tisiac"), "title": [ "pharmacy Tech (Piaran) - retail Pharmacy "]," travel ": [" nn "]}, ...  

how does this look like my model:

  class health (models .model): location = model.carfield (max_length = 32) title = model.carfield (max_length = 64) LOCATION_TYPE = models.chhar Field (MAX_LENGTH = 32) job_id = models.CharField (MAX_LENGTH = 16) Department = models.CharField (MAX_LENGTH = 24) area_of_interest = models.CharField (MAX_LENGTH = 32) job_type = models.CharField (MAX_LENGTH = 32) poly = models. CharField (MAX_LENGTH = 32) transfer = models.CharField (MAX_LENGTH = 8) travel = models.CharField (MAX_LENGTH = 8) feature = models.CharField (MAX_LENGTH = 32) job_function = models.CharField (MAX_LENGTH = 96) = duties models. As I am new to Django, I was talking about several posts and blows, how to read the GSM file from the Django and postgresclose to the data. GS, but most of the posts were related to JavaScript, which I do not know.  

So my question is, how do I read the data from the JSA file and how do I store the fields in the PostGreyskil database using DJGongo?

Thank you in advance

View the document of build-in modules for reference How to make json pars and reference How to make batch inserts

Sample code (untested):

  # Read file f = open ('path_to_file. Json ') json_string = f.read () f.close () Dragon object import = json data = json.loads (json_string) # to #convert json string Create model instances for each item items = [] For: example # models Make up .. item = your model (* item) items Append (items) # create your own in a query YourModel.objects.bulk_create (item)  

Comments