django 將model轉換為字典
阿新 • • 發佈:2018-09-10
des stat get create ron ear utc version sim
from django.forms.models import model_to_dict from projects.models import ProjectInformation site = ProjectInformation.objects.get(id=6) dict = model_to_dict(site) dict {‘CRFmethod‘: ‘‘, ‘EDCprovider‘: ‘‘, ‘acceptancenum‘: ‘‘, ‘add_time‘: datetime.datetime(2017, 4, 20, 8, 4, 42, 751202, tzinfo=<UTC>), ‘begindate‘: None, ‘clinicalassis‘: ‘‘, ‘clinicalnum‘: ‘‘, ‘created_by‘: ‘‘, ‘created_date‘: None, ‘enddate‘: None, ‘ethicsreviewdate‘: None, ‘ethicsreviewpers‘: ‘‘, ‘ethicsreviewres‘: ‘‘, ‘ethicsreviewunit‘: ‘‘, ‘id‘: 6, ‘isimport‘: None, ‘leaderunit‘: None, ‘localcases‘: None, ‘medicalequipment‘: ‘‘, ‘mequipmenttype‘: ‘‘, ‘multicenter‘: ‘‘, ‘plannum‘: ‘‘, ‘proenname‘: ‘愛上地方‘, ‘proname‘: ‘打士大夫‘, ‘prostatus‘: ‘‘, ‘prosummary‘: ‘‘, ‘protype‘: ‘打是否‘, ‘regstudy‘: ‘是‘, ‘reportdate‘: None, ‘reportnum‘: ‘‘, ‘reportversion‘: ‘‘, ‘researchdesign‘: ‘‘, ‘researchtype‘: ‘‘, ‘responsible‘: ‘‘, ‘studytype‘: ‘器械類‘, ‘telephonenum‘: None, ‘totalcases‘: None, ‘treatmenttype‘: None, ‘unitnum‘: None}
https://www.cnblogs.com/zhaoyingjie/p/6742879.html
django 將model轉換為字典