django QuerySet对象转换成字典对象

>>> from django.contrib.auth.models import User

>>> from django.forms.models import model_to_dict

>>> u = User.objects.get(id=1)

>>> u_dict = model_to_dict(u)

>>> type(u) <class 'django.contrib.auth.models.User'>

>>> type(u_dict) <type 'dict'>

posted @ 2018-09-09 12:29  核电站  阅读(4693)  评论(0编辑  收藏  举报