#11310: Unable to serialize ManyToMany fields with "trough" ---------------------------------------------------+------------------------ Reporter: Pavel Schön <pa...@schon.cz> | Owner: nobody Status: reopened | Milestone: Component: Serialization | Version: SVN Resolution: | Keywords: ManyToMany Stage: Unreviewed | Has_patch: 1 Needs_docs: 0 | Needs_tests: 0 Needs_better_patch: 0 | ---------------------------------------------------+------------------------ Changes (by pa...@schon.cz):
* status: closed => reopened * version: 1.0 => SVN * resolution: worksforme => Comment: Hi, look at this example: {{{ class A(models.Model): foo = models.CharField(max_length=32) # b = models.ManyToManyField('B', through='A_B') b = models.ManyToManyField('B') class B(models.Model): bar = models.CharField(max_length=32) class A_B(models.Model): a = models.ForeignKey('A') b = models.ForeignKey('B') }}} Then i run: {{{ >>> from django.core.serializers import serialize >>> serialize('python', A.objects.all()) [{'pk': 1L, 'model': u'testapp.a', 'fields': {'foo': u'eeeee', 'b': [1L]}}] }}} This is OK. Now I change models to this: {{{ class A(models.Model): foo = models.CharField(max_length=32) b = models.ManyToManyField('B', through='A_B') # b = models.ManyToManyField('B') class B(models.Model): bar = models.CharField(max_length=32) class A_B(models.Model): a = models.ForeignKey('A') b = models.ForeignKey('B') }}} I serialize it: {{{ >>> from django.core.serializers import serialize >>> serialize('python', A.objects.all()) [{'pk': 1L, 'model': u'testapp.a', 'fields': {'foo': u'eeeee'}}] }}} 'b' is missing in output... -- Ticket URL: <http://code.djangoproject.com/ticket/11310#comment:3> Django <http://code.djangoproject.com/> The Web framework for perfectionists with deadlines. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-updates?hl=en -~----------~----~----~----~------~----~------~--~---