Commit 9a33d3d7 authored by Alexander Gaevsky's avatar Alexander Gaevsky Committed by Tim Graham
Browse files

Fixed #26060 -- Fixed crash with reverse OneToOneField in ModelAdmin.readonly_fields.

parent fb4272f0
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -383,7 +383,7 @@ def help_text_for_field(name, model):
def display_for_field(value, field, empty_value_display):
    from django.contrib.admin.templatetags.admin_list import _boolean_icon

    if field.flatchoices:
    if getattr(field, 'flatchoices', None):
        return dict(field.flatchoices).get(value, empty_value_display)
    # NullBooleanField needs special-case null-handling, so it comes
    # before the general null test.
+3 −0
Original line number Diff line number Diff line
@@ -26,3 +26,6 @@ Bugfixes

* Fixed a crash when using an ``__in`` lookup inside a ``Case`` expression
  (:ticket:`26071`).

* Fixed a crash when using a reverse ``OneToOneField`` in
  ``ModelAdmin.readonly_fields`` (:ticket:`26060`).
+3 −0
Original line number Diff line number Diff line
@@ -49,3 +49,6 @@ Bugfixes
  SQLite with more than 2000 parameters when :setting:`DEBUG` is ``True`` on
  distributions that increase the ``SQLITE_MAX_VARIABLE_NUMBER`` compile-time
  limit to over 2000, such as Debian (:ticket:`26063`).

* Fixed a crash when using a reverse ``OneToOneField`` in
  ``ModelAdmin.readonly_fields`` (:ticket:`26060`).
+15 −9
Original line number Diff line number Diff line
@@ -35,15 +35,16 @@ from .models import (
    InlineReference, InlineReferer, Inquisition, Language, Link,
    MainPrepopulated, ModelWithStringPrimaryKey, NotReferenced, OldSubscriber,
    OtherStory, Paper, Parent, ParentWithDependentChildren, ParentWithUUIDPK,
    Person, Persona, Picture, Pizza, Plot, PlotDetails, PluggableSearchPerson,
    Podcast, Post, PrePopulatedPost, PrePopulatedPostLargeSlug,
    PrePopulatedSubPost, Promo, Question, Recipe, Recommendation, Recommender,
    ReferencedByGenRel, ReferencedByInline, ReferencedByParent,
    RelatedPrepopulated, RelatedWithUUIDPKModel, Report, Reservation,
    Restaurant, RowLevelChangePermissionModel, Section, ShortMessage, Simple,
    Sketch, State, Story, StumpJoke, Subscriber, SuperVillain, Telegram, Thing,
    Topping, UnchangeableObject, UndeletableObject, UnorderedObject,
    UserMessenger, Villain, Vodcast, Whatsit, Widget, Worker, WorkHour,
    Person, Persona, Picture, Pizza, Plot, PlotDetails, PlotProxy,
    PluggableSearchPerson, Podcast, Post, PrePopulatedPost,
    PrePopulatedPostLargeSlug, PrePopulatedSubPost, Promo, Question, Recipe,
    Recommendation, Recommender, ReferencedByGenRel, ReferencedByInline,
    ReferencedByParent, RelatedPrepopulated, RelatedWithUUIDPKModel, Report,
    Reservation, Restaurant, RowLevelChangePermissionModel, Section,
    ShortMessage, Simple, Sketch, State, Story, StumpJoke, Subscriber,
    SuperVillain, Telegram, Thing, Topping, UnchangeableObject,
    UndeletableObject, UnorderedObject, UserMessenger, Villain, Vodcast,
    Whatsit, Widget, Worker, WorkHour,
)


@@ -866,6 +867,10 @@ class InlineRefererAdmin(admin.ModelAdmin):
    inlines = [InlineReferenceInline]


class PlotReadonlyAdmin(admin.ModelAdmin):
    readonly_fields = ('plotdetails',)


class GetFormsetsArgumentCheckingAdmin(admin.ModelAdmin):
    fields = ['name']

@@ -920,6 +925,7 @@ site.register(Villain)
site.register(SuperVillain)
site.register(Plot)
site.register(PlotDetails)
site.register(PlotProxy, PlotReadonlyAdmin)
site.register(Bookmark)
site.register(CyclicOne)
site.register(CyclicTwo)
+6 −1
Original line number Diff line number Diff line
@@ -538,12 +538,17 @@ class Plot(models.Model):
@python_2_unicode_compatible
class PlotDetails(models.Model):
    details = models.CharField(max_length=100)
    plot = models.OneToOneField(Plot, models.CASCADE)
    plot = models.OneToOneField(Plot, models.CASCADE, null=True, blank=True)

    def __str__(self):
        return self.details


class PlotProxy(Plot):
    class Meta:
        proxy = True


@python_2_unicode_compatible
class SecretHideout(models.Model):
    """ Secret! Not registered with the admin! """
Loading