Changes between Initial Version and Version 1 of Ticket #29981


Ignore:
Timestamp:
Nov 23, 2018, 1:17:15 PM (5 years ago)
Author:
Tim Graham
Comment:

I reproduced the issue on master (78fc64578a8715b9812075bbebc829c1251c07fa). I removed AnotherEntryDetailInline from the description as it doesn't seem required to reproduce the issue.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #29981

    • Property Triage Stage UnreviewedAccepted
    • Property Summary invalid_choice error when changing InlineModel with a OneToOne relation via to_field"Please correct the error below." (with no errors displayed) when changing an inline that has a one-to-one relation to the parent that uses to_field
  • Ticket #29981 – Description

    initial v1  
    1212    title = models.CharField(max_length=255, blank=True, null=True)
    1313
    14     class Meta:
    15         verbose_name_plural = 'Entries'
    16 
    1714class EntryDetail(models.Model):
    1815    entry = models.OneToOneField(
     
    2320    )
    2421    description = models.TextField(blank=True, null=True)
    25 
    26 class AnotherEntryDetail(models.Model):
    27     entry = models.OneToOneField(
    28         Entry,
    29         primary_key=True,
    30         on_delete=models.CASCADE
    31     )
    32     otherdescription = models.TextField(blank=True, null=True)
    3322}}}
    34 
    3523
    3624admin.py
     
    3826{{{
    3927from django.contrib import admin
    40 from .models import Entry, EntryDetail, AnotherEntryDetail
     28from .models import Entry, EntryDetail
    4129
    4230class EntryDetailInline(admin.StackedInline):
    4331    model = EntryDetail
    4432
    45 class AnotherEntryDetailInline(admin.StackedInline):
    46     model = AnotherEntryDetail
    47 
    4833@admin.register(Entry)
    4934class EntryAdmin(admin.ModelAdmin):
    50     inlines = [
    51         EntryDetailInline,
    52         AnotherEntryDetailInline
    53     ]
     35    inlines = [EntryDetailInline]
    5436
    5537    def get_readonly_fields(self, request, obj=None):
     
    6345}}}
    6446
    65 
    66 **Expected behavior:**
    67 
    68 In the admin:
    69 * add an Entry
    70 * fill slug and "Another entry detail" description
    71 * save
    72 * (change "Another entry detail" description)
    73 * **save**
    74 
    75 
    7647**Steps to reproduce the bug:**
    7748
    7849In the admin:
    7950* add an Entry
    80 * fill slug and "Entry detail" description
     51* fill slug, title, and "Entry detail" description
     52* save and continue editing
     53* change "Entry detail" description
    8154* save
    82 * (change "Entry detail" description)
    83 * **save**
    84 * Error message in admin: "Please correct the error below."
    85 
     55* Error message in admin: "Please correct the error below." (with no errors listed). `formset[0].errors` is `[{'entry': ['The inline value did not match the parent instance.']}]` which comes from `InlineForeignKeyField` value is `aaa` and `orig` is `1`.
    8656
    8757**Workaround:**
     
    11080    formset = EntryDetailFormSet
    11181}}}
    112 
    113 
    114 ''Sorry for the confusing ticket-title, i couldn't come up with something better.''
Back to Top