Code

Ticket #4187: __init__.py.diff

File __init__.py.diff, 861 bytes (added by sandro.turriate@…, 7 years ago)

fix python deserialization for manage.py loaddata

Line 
1Index: __init__.py
2===================================================================
3--- __init__.py (revision 5127)
4+++ __init__.py (working copy)
5@@ -75,6 +75,9 @@
6     list_of_related_objects}``.
7     """
8     d = get_deserializer(format)
9+    if format == "python":
10+        data = stream_or_string.readline() #read the line
11+        stream_or_string = eval(data) #eval the line returning a python list of objects
12     return d(stream_or_string)
13 
14 def _load_serializers():
15@@ -87,4 +90,4 @@
16         register_serializer(format, BUILTIN_SERIALIZERS[format])
17     if hasattr(settings, "SERIALIZATION_MODULES"):
18         for format in settings.SERIALIZATION_MODULES:
19-            register_serializer(format, settings.SERIALIZATION_MODULES[format])
20\ No newline at end of file
21+            register_serializer(format, settings.SERIALIZATION_MODULES[format])