Ticket #33974: test_serializer.py

File test_serializer.py, 495 bytes (added by Arthur Hanson, 2 years ago)

management command that shows the issue

Line 
1from django.core.management.base import BaseCommand, CommandError
2from serializertest.models import Board
3from django.core.serializers import serialize
4import json
5
6class Command(BaseCommand):
7 help = ''
8
9 def handle(self, *args, **options):
10 obj = Board.objects.first()
11 if not obj:
12 pieces = [1, 3, 5]
13 obj = Board()
14 obj.pieces = pieces
15 obj.save()
16
17 print(serialize('json', [obj]))
18 print(json.dumps(obj.pieces))
Back to Top