解决办法:利用django.forms.modelsh中的model_to_dict方法
>manage.py shell
>>> 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'>
网友评论