Re: [Django] #11310: Unable to serialize ManyToMany fields with "trough"

2009-07-29 Thread Django
#11310: Unable to serialize ManyToMany fields with "trough"
---+
  Reporter:  Pavel Schön   | Owner:  nobody
Status:  closed| Milestone:
 Component:  Serialization |   Version:  SVN   
Resolution:  worksforme|  Keywords:  ManyToMany
 Stage:  Unreviewed| Has_patch:  1 
Needs_docs:  0 |   Needs_tests:  0 
Needs_better_patch:  0 |  
---+
Changes (by russellm):

  * status:  reopened => closed
  * resolution:  => worksforme

Comment:

 Your example code is explicitly serializing objects of type A. However,
 when you have a through relationship, you need to serialize the A_B model
 separately, since that model could contain extra data.

 When you don't have a through model, there isn't an actual model
 representing the through relationship., so the m2m data is included on the
 A model as a list of related objects.

-- 
Ticket URL: 
Django 
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
-~--~~~~--~~--~--~---



Re: [Django] #11310: Unable to serialize ManyToMany fields with "trough"

2009-07-29 Thread Django
#11310: Unable to serialize ManyToMany fields with "trough"
---+
  Reporter:  Pavel Schön   | Owner:  nobody
Status:  closed| Milestone:
 Component:  Serialization |   Version:  SVN   
Resolution:  worksforme|  Keywords:  ManyToMany
 Stage:  Unreviewed| Has_patch:  1 
Needs_docs:  0 |   Needs_tests:  0 
Needs_better_patch:  0 |  
---+
Comment (by pa...@schon.cz):

 s/XMLRPCSerializer/CustomSerializer/g

-- 
Ticket URL: 
Django 
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
-~--~~~~--~~--~--~---



Re: [Django] #11310: Unable to serialize ManyToMany fields with "trough"

2009-07-29 Thread Django
#11310: Unable to serialize ManyToMany fields with "trough"
---+
  Reporter:  Pavel Schön   | Owner:  nobody
Status:  closed| Milestone:
 Component:  Serialization |   Version:  SVN   
Resolution:  worksforme|  Keywords:  ManyToMany
 Stage:  Unreviewed| Has_patch:  1 
Needs_docs:  0 |   Needs_tests:  0 
Needs_better_patch:  0 |  
---+
Comment (by pa...@schon.cz):

 Thanks for explanation. I was migrating some models without 'through' to
 use 'through' and serialization behaviour was changed. I made a wraparound
 of this using custom serializer:

 {{{
 class CustomSerializer(python.Serializer):
 def handle_m2m_field(self, obj, field):
 field.creates_table = True
 super(XMLRPCSerializer, self).handle_m2m_field(obj, field)
 }}}
 Yeah, it's ugly, but it works ;-)

-- 
Ticket URL: 
Django 
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
-~--~~~~--~~--~--~---



Re: [Django] #11310: Unable to serialize ManyToMany fields with "trough"

2009-07-29 Thread Django
#11310: Unable to serialize ManyToMany fields with "trough"
---+
  Reporter:  Pavel Schön   | 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'e', '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'e'}}]
 }}}
 'b' is missing in output...

-- 
Ticket URL: 
Django 
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
-~--~~~~--~~--~--~---



Re: [Django] #11310: Unable to serialize ManyToMany fields with "trough"

2009-07-11 Thread Django
#11310: Unable to serialize ManyToMany fields with "trough"
---+
  Reporter:  Pavel Schön   | Owner:  nobody
Status:  closed| Milestone:
 Component:  Serialization |   Version:  1.0   
Resolution:  worksforme|  Keywords:  ManyToMany
 Stage:  Unreviewed| Has_patch:  1 
Needs_docs:  0 |   Needs_tests:  0 
Needs_better_patch:  0 |  
---+
Changes (by russellm):

  * status:  new => closed
  * resolution:  => worksforme

Comment:

 The test suite contains a test to validate that serialization works for
 m2m with a through field (see the
 
[http://code.djangoproject.com/browser/django/trunk/tests/regressiontests/m2m_through_regress/models.py
 regressiontests/m2m_through_regress tests). Without a test case showing a
 specific failure case I'm going to mark this worksforme.

-- 
Ticket URL: 
Django 
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
-~--~~~~--~~--~--~---



Re: [Django] #11310: Unable to serialize ManyToMany fields with "trough"

2009-06-12 Thread Django
#11310: Unable to serialize ManyToMany fields with "trough"
---+
  Reporter:  Pavel Schön   | Owner:  nobody
Status:  new   | Milestone:
 Component:  Serialization |   Version:  1.0   
Resolution:|  Keywords:  ManyToMany
 Stage:  Unreviewed| Has_patch:  1 
Needs_docs:  0 |   Needs_tests:  0 
Needs_better_patch:  0 |  
---+
Changes (by Pavel Schön ):

  * needs_better_patch:  => 0
  * component:  Uncategorized => Serialization
  * needs_tests:  => 0
  * keywords:  => ManyToMany
  * needs_docs:  => 0
  * has_patch:  0 => 1

-- 
Ticket URL: 
Django 
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
-~--~~~~--~~--~--~---



[Django] #11310: Unable to serialize ManyToMany fields with "trough"

2009-06-12 Thread Django
#11310: Unable to serialize ManyToMany fields with "trough"
--+-
 Reporter:  Pavel Schön   |   Owner:  nobody
   Status:  new   |   Milestone:
Component:  Uncategorized | Version:  1.0   
 Keywords:|   Stage:  Unreviewed
Has_patch:  0 |  
--+-
 Problem is, that ManyToMany field with intermediate table is ignored in
 PythonSerializer. This patch should fix it.

 {{{
 
http://code.djangoproject.com/svn/django/trunk/django/core/serializers/python.py
 59,61c59,60
 < if field.creates_table:
 < self._current[field.name] =
 [smart_unicode(related._get_pk_val(), strings_only=True)
  self._current[field.name] =
 [smart_unicode(related._get_pk_val(), strings_only=True)
 > for related in getattr(obj, field.name).iterator()]
 }}}

-- 
Ticket URL: 
Django 
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
-~--~~~~--~~--~--~---