Commit 2456276b authored by Tim Graham's avatar Tim Graham
Browse files

[1.8.x] Fixed #24851 -- Fixed crash with reverse one-to-one relation in ModelAdmin.list_display

parent f65d4db8
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -200,7 +200,7 @@ def items_for_result(cl, result, form):
        except ObjectDoesNotExist:
            result_repr = EMPTY_CHANGELIST_VALUE
        else:
            if f is None:
            if f is None or f.auto_created:
                if field_name == 'action_checkbox':
                    row_classes = ['action-checkbox']
                allow_tags = getattr(attr, 'allow_tags', False)
+1 −1
Original line number Diff line number Diff line
@@ -383,7 +383,7 @@ class ChangeList(object):
            except FieldDoesNotExist:
                pass
            else:
                if isinstance(field.rel, models.ManyToOneRel):
                if hasattr(field, 'rel') and isinstance(field.rel, models.ManyToOneRel):
                    return True
        return False

+3 −0
Original line number Diff line number Diff line
@@ -28,3 +28,6 @@ Bugfixes

* Prevented the loss of ``null``/``not null`` column properties during field
  renaming of MySQL databases (:ticket:`24817`).

* Fixed a crash when using a reverse one-to-one relation in
  ``ModelAdmin.list_display`` (:ticket:`24851`).
+1 −1
Original line number Diff line number Diff line
@@ -102,7 +102,7 @@ site.register(Parent, NoListDisplayLinksParentAdmin)

class SwallowAdmin(admin.ModelAdmin):
    actions = None  # prevent ['action_checkbox'] + list(list_display)
    list_display = ('origin', 'load', 'speed')
    list_display = ('origin', 'load', 'speed', 'swallowonetoone')

site.register(Swallow, SwallowAdmin)

+4 −0
Original line number Diff line number Diff line
@@ -78,6 +78,10 @@ class Swallow(models.Model):
        ordering = ('speed', 'load')


class SwallowOneToOne(models.Model):
    swallow = models.OneToOneField(Swallow)


class UnorderedObject(models.Model):
    """
    Model without any defined `Meta.ordering`.
Loading