Code

Opened 4 years ago

Closed 4 years ago

Last modified 3 years ago

#14034 closed (worksforme)

admin inline formset with "extra" ignores last line when saving

Reported by: qnix Owned by: nobody
Component: Contrib apps Version: 1.2
Severity: Keywords: admin, save, inline
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

I defined my inline admin model such this:

class ServiceOptionInline(admin.TabularInline):
    model = ServiceOption
    extra = 2

In the web page, I always see "extra + 1" empty inline lines to add new records. I think it's normal since there is no max_num defined. However the last line is never saved. So, there are only "extra" lines saved during the save operation. Currently, I've made a simple hack in JS that hide/delete the last row of the inline form.

Could you confirm that this is a bug and not only happens here?

Attachments (0)

Change History (2)

comment:1 Changed 4 years ago by kmtracey

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to worksforme
  • Status changed from new to closed

I can't recreate the behavior you describe. First, with extra=2 and no max_num in an inline definition, I see 2 empty inlines to add new records, not 3, so having extra+1 empty inlines showing up indicates something off somewhere -- I do not recall ever seeing that behavior. I don't understand the comment about no max_num explaining that behavior. You may see fewer than extra empty forms, if adding the specified number extra forms would cause the total number to exceed max_num, but I don't recall any conditions where you should get more than extra empty inlines showing up.

Second, in my tests all inlines that have data entered before pressing save are in fact validated and saved.

I think there must be some additional information about your setup/configuration you have not included here that explains what is going on; so far as I can see there is not a bug in Django here.

comment:2 Changed 3 years ago by jacob

  • milestone 1.3 deleted

Milestone 1.3 deleted

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.