Ticket #13834: natural_key_assertion.diff

File natural_key_assertion.diff, 677 bytes (added by Claude Paroz, 14 years ago)

Add an assertion about natural_key method return value type

  • django/core/serializers/python.py

     
    4949        if related is not None:
    5050            if self.use_natural_keys and hasattr(related, 'natural_key'):
    5151                related = related.natural_key()
     52                assert isinstance(related, tuple), \
     53                        'natural_key methods should always return a tuple'
    5254            else:
    5355                if field.rel.field_name == related._meta.pk.name:
    5456                    # Related to remote object via primary key
Back to Top