django 中model 的序列换
方法一:
from
django.core
import
serializers
ret
=
models.BookType.objects.
all
()
data
=
serializers.serialize(
"json"
, ret)
方法二:
当只有一个object时:
from django.forms.models import model_to_dict
data = model_to_dict(your model object)