我有以下 Django 模型
class ConfigurationItem(models.Model):
path = models.CharField('Path', max_length=1024)
name = models.CharField('Name', max_length=1024, blank=True)
description = models.CharField('Description', max_length=1024, blank=True)
active = models.BooleanField('Active', default=True)
is_leaf = models.BooleanField('Is a Leaf item', default=True)
class Location(ConfigurationItem):
address = models.CharField(max_length=1024, blank=True)
phoneNumber = models.CharField(max_length=255, blank=True)
url = models.URLField(blank=True)
read_acl = models.ManyToManyField(Group, default=None)
write_acl = models.ManyToManyField(Group, default=None)
alert_group= models.EmailField(blank=True)
Run Code Online (Sandbox Code Playgroud)
如果有帮助,完整的模型文件在这里。
您可以看到 Company 是 ConfigurationItem 的子类。
我正在尝试使用 django.core.serializers.serializer 或 WadofStuff 序列化器来使用 JSON 序列化。
两个序列化器给我同样的问题......
>>> from cmdb.models import *
>>> from django.core import serializers
>>> …Run Code Online (Sandbox Code Playgroud)