Impossible to create inline objects if form validates but is unchanged
|Reported by:||julien||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Here's a simple test case:
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)
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.
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