Ticket #7202: o2o_fixture_load_r7540.diff

File o2o_fixture_load_r7540.diff, 680 bytes (added by zhaoz, 16 years ago)

The fix, sets parent's pk so update/save new works correctly.

  • django/core/serializers/python.py

     
    6969        data = {Model._meta.pk.attname : Model._meta.pk.to_python(d["pk"])}
    7070        m2m_data = {}
    7171
     72        if Model._meta.pk.rel and isinstance(Model._meta.pk.rel, models.OneToOneRel):
     73            rel = Model._meta.pk.rel
     74            data[rel.to._meta.pk.attname] = data[Model._meta.pk.attname]
     75
    7276        # Handle each field
    7377        for (field_name, field_value) in d["fields"].iteritems():
    7478            if isinstance(field_value, str):
Back to Top