mattimustang / wadofstuff

Automatically exported from code.google.com/p/wadofstuff
10 stars 6 forks source link

In 'python' serialization mode, relations directive is not honored #12

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I have a Recommendation model, where a User can rate a Content. When I try 
to serialize a queryset with Recommendation objects, 'json' serializer 
correctly handles relations=('content',), but 'python' serializer does not.

>>> serializers.serialize('python', recommendations, 
relations=('content',))
[{'pk': 18L, 'model': u'content.recommendation', 'fields': {'content': 1L, 
'rating': 5, 'last_updated': datetime.datetime(2010, 5, 4, 12, 28, 21), 
'user': 1L}}]

>>> serializers.serialize('json', recommendations, relations=('content',)) 
'[{"pk": 18, "model": "content.recommendation", "fields": {"content": 
{"pk": 1, "model": "content.content", "fields": {"url": 
"http://localhost:8585/site_media/content/qybUFnY7Y8w.flv", "description": 
"Some test content", "uid": "qybUFnY7Y8w", "title": "Test Content"}}, 
"rating": 5, "last_updated": "2010-05-04 12:28:21", "user": 1}}]' 

Original issue reported on code.google.com by eugene.k...@gmail.com on 10 May 2010 at 6:40

GoogleCodeExporter commented 9 years ago
What is your SERIALIZATION_MODULES in settings.py?

Original comment by mattimus...@gmail.com on 10 May 2010 at 11:30

GoogleCodeExporter commented 9 years ago
Ahh, thank you! Of course I hadn't configured it for python correctly... Didn't 
even 
occur to me to check. A case of blindly following the documentation without 
thinking 
about what I was doing. Works fine now.

Original comment by eugene.k...@gmail.com on 10 May 2010 at 11:41

GoogleCodeExporter commented 9 years ago

Original comment by mattimus...@gmail.com on 11 May 2010 at 1:34