Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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)
- >>> from cmdb.models import *
- >>> from django.core import serializers
- >>> serializers.serialize('json', [ ConfigurationItem.objects.get(id=7)])
- '[{"pk": 7, "model": "cmdb.configurationitem", "fields": {"is_leaf": true, "extension_attribute_10": "", "name": "", "date_modified": "2010-05-19 14:42:53", "extension_attribute_11": false, "extension_attribute_5": "", "extension_attribute_2": "", "extension_attribute_3": "", "extension_attribute_1": "", "extension_attribute_6": "", "extension_attribute_7": "", "extension_attribute_4": "", "date_created": "2010-05-19 14:42:53", "active": true, "path": "/Locations/London", "extension_attribute_8": "", "extension_attribute_9": "", "description": ""}}]'
- >>> serializers.serialize('json', [ Location.objects.get(id=7)])
- '[{"pk": 7, "model": "cmdb.location", "fields": {"write_acl": [], "url": "", "phoneNumber": "", "address": "", "read_acl": [], "alert_group": ""}}]'
- >>>
- serializer = AllFieldsSerializer()
- serializer.serialize(queryset, fields=fields)
- print serializer.getvalue()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement