MrLoick / app-engine-patch

Automatically exported from code.google.com/p/app-engine-patch
0 stars 0 forks source link

When serializing models, the reverse Reference Property is not present. #226

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

My models are defined in a one-to-many relationship, like this example :
class Contact(db.Model):
  # Basic info.
  name = db.StringProperty()
  birth_day = db.DateProperty()

class PhoneNumber(db.Model):
  contact = db.ReferenceProperty(Contact,
                                 collection_name='phone_numbers')
  phone_type = db.StringProperty(
    choices=('home', 'work', 'fax', 'mobile', 'other'))
  number = db.PhoneNumberProperty()

What is the expected output? What do you see instead?

When doing :
from django.core import serializers
data = serializers.serialize('xml', Contact.all())

data doesn't contain any reference to 'phone_numbers'.

What version of the product are you using? On what operating system?
Using app-engine-patch 1.0.2.3 on Mac OS X 10.5.8

Please provide any additional information below.

I have investigated a little bit, and Contact.phone_numbers is a : 

google.appengine.ext.db._ReverseReferenceProperty object
and it is not included in Contact.properties().values() therefore not added in 
the Contact._meta by 
patch.py.

Original issue reported on code.google.com by matthieu...@gmail.com on 8 Oct 2009 at 7:05

GoogleCodeExporter commented 8 years ago
Well, assuming db.ReferenceProperty is an GAE storage equivalent to Django's
models.ForeignKey. it isn't expected at all that a model referenced by such a 
field
dumps the reverse when serializing it.

Original comment by cra...@gmail.com on 12 Jan 2010 at 1:42