Opened 5 years ago

Last modified 17 months ago

#14832 new Bug

Impossible to create inline objects if form validates but is unchanged

Reported by: julien Owned by: nobody
Component: contrib.admin Version: 1.4
Severity: Normal Keywords: sprintdec2010
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: yes

Description

Here's a simple test case:

Models:

from django.db import models

class Account(models.Model):
    name = models.CharField(max_length=100)
    
class Expense(models.Model):
    account = models.ForeignKey(Account)
    amount = models. IntegerField(default=100, blank=True, null=True)
    memo = models.CharField(max_length=100, blank=True)

Admin:

from django.contrib import admin

from .models import Account, Expense

class ExpenseInlineAdmin(admin.TabularInline):
    model = Expense

class AccountAdmin(admin.ModelAdmin):
    inlines = [ExpenseInlineAdmin]

admin.site.register(Account, AccountAdmin)

Here there is no way to create an expense object with the amount 100 and no memo. This is because Django compares the submitted values with the initial ones, and takes a (big) guess that the user wants to create an object only because she has *modified* one of the values. If the user is happy with the default values and presses 'save', then the expense object won't get created.

I've discussed this at length with DrMeers and russellm during the Dec2010 sprint. I am conscious that there is no straight forward solution to this, and that this approach was designed prior the inclusion of jquery and also to allow people without javascript to use inlines. However it seems that this system is either flawed by design, or confusing to say the least (as people rely on this behaviour and expect things to work the way they really shouldn't, i.e. #14095).

It feels that some user interface design work needs to be done to make things more explicit and intuitive. Opening this ticket to keep track of this request, as I expect some design discussions need to happen on the mailing list in parallel.

Change History (7)

comment:1 Changed 5 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

This is a messy problem, and needs some UX love to work out the right solution.

comment:2 Changed 4 years ago by julien

#15174 was closed as dupe (different use case but essentially the same problem).

comment:3 Changed 4 years ago by jaddison

  • Severity set to Normal
  • Type set to Bug

comment:4 Changed 4 years ago by julien

  • Easy pickings unset

#11807 reported the same issue, contains a detailed analysis by kmtracey and has a test case.

comment:5 Changed 4 years ago by julien

  • UI/UX set

comment:6 Changed 17 months ago by wim@…

  • Version changed from 1.2 to 1.4

comment:7 Changed 17 months ago by anonymous

The problem still exists in Django 1.4.10

Note: See TracTickets for help on using tickets.
Back to Top