Opened 3 years ago

Closed 3 years ago

#20464 closed Bug (fixed)

admin list_editable displays wrong error messages

Reported by: Marc Egli Owned by: Baptiste Mispelon
Component: Forms Version: master
Severity: Normal Keywords: admin
Cc: bmispelon@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

Considering the following ModelAdmin:

class SomeModelAdmin(admin.ModelAdmin):
    list_display = ('pk', 'one', 'two')
    list_editable = ('one', 'two')

If you have errors in your form there is either Please correct the error below. or Please correct the errors below.. But this distinction is made on the count of forms having errors not on the total error count.

  • If you have one entry and manage to have errors in both fields then it uses Please correct the error below.
  • If you have two entries and you have one error in one of them it says Please correct the errors below.

Change History (5)

comment:1 Changed 3 years ago by Kamu

Easy pickings: set
Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
UI/UX: set

comment:2 Changed 3 years ago by Baptiste Mispelon

Cc: bmispelon@… added
Triage Stage: UnreviewedAccepted

comment:3 Changed 3 years ago by Baptiste Mispelon

Owner: changed from nobody to Baptiste Mispelon
Status: newassigned

I'm looking into it and the issue stems from the fact that {{ formset.error }} is a list that has as many elements as the number of forms in the formset.

To fix this, I'm thinking of introducing a new method on formsets: total_error_count that would count all the actual errors.

I'll have a pull request ready soon.

comment:4 Changed 3 years ago by Baptiste Mispelon

Component: contrib.adminForms
Has patch: set
UI/UX: unset

comment:5 Changed 3 years ago by Tim Graham <timograham@…>

Resolution: fixed
Status: assignedclosed

In 1b7634a0d0e21faba71a27ae7951d7cb7aec0e49:

Fixed #20464 -- Added a total_error_count method on formsets.

Thanks to frog32 for the report and to Tim Graham for the review.

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