Commit 75528786 authored by Malcolm Tredinnick's avatar Malcolm Tredinnick
Browse files

Fixed #8841 -- Fixed a case of ForeignKeys to models constructed with

inheritance.

This patch is uglier than it needs to be (see comment in patch) to ensure no
accidental bug is introduced just before 1.0. We'll clean it up later.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@8957 bcc190cf-cafb-0310-a4f2-bffc1f526a37
parent c9496656
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -570,6 +570,12 @@ class ModelChoiceIterator(object):

    def choice(self, obj):
        if self.field.to_field_name:
            # FIXME: The try..except shouldn't be necessary here. But this is
            # going in just before 1.0, so I want to be careful. Will check it
            # out later.
            try:
                key = getattr(obj, self.field.to_field_name).pk
            except AttributeError:
                key = getattr(obj, self.field.to_field_name)
        else:
            key = obj.pk