Opened 7 years ago

Closed 7 years ago

#8957 closed (fixed)

Typo in Admin validation exception message

Reported by: charmless Owned by: nobody
Component: contrib.admin Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

If a prepopulated_fields value refers to a nonexistant field, the error message is in correct.

So for:

   prepopulated_fields = {'slug': ['field_which_doesnt_exist']}

The error raised is:

'SomeAdmin.prepopulated_fields['field_which_doesnt_exist'][0]' refers to field 'field_which_doesnt_exist' that is missing from model 'Release'.

The expected error should finger 'slug' as the key with the offending source field:

'SomeAdmin.prepopulated_fields['slug'][0]' refers to field 'field_which_doesnt_exist' that is missing from model 'Release'.

This is a simple typo. Fix attached.

Attachments (2)

8966-charmless-admin-validation-prepopulated-type.diff (549 bytes) - added by charmless 7 years ago.
patch.
8957-expected-result-patch.diff (818 bytes) - added by morty 7 years ago.
Patch

Download all attachments as: .zip

Change History (7)

Changed 7 years ago by charmless

patch.

comment:1 Changed 7 years ago by adrian

  • Resolution set to fixed
  • Status changed from new to closed

(In [9002]) Fixed #8957 -- Fixed incorrect error message when Admin prepopulated_fields refers to a field that does not exist. Thanks, charmless

comment:2 follow-up: Changed 7 years ago by morty

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution fixed deleted
  • Status changed from closed to reopened

Reopening this ticket as the test still fails in the same way as initially described.

comment:3 in reply to: ↑ 2 ; follow-up: Changed 7 years ago by morty

Replying to morty:

Reopening this ticket as the test still fails in the same way as initially described.

Sorry, it isn't exactly as described. The output of the failing test is:

Failed example:
    validate(ValidationTestModelAdmin, ValidationTestModel)
Expected:
    Traceback (most recent call last):
    ...
    ImproperlyConfigured: 'ValidationTestModelAdmin.prepopulated_fields['non_existent_field'][0]' refers to field 'non_existent_field' that is missing from model 'ValidationTestModel'.
Got:
    Traceback (most recent call last):
    ...
    ImproperlyConfigured: 'ValidationTestModelAdmin.prepopulated_fields['slug'][0]' refers to field 'non_existent_field' that is missing from model 'ValidationTestModel'.

comment:4 in reply to: ↑ 3 Changed 7 years ago by morty

I think that the test is at fault. The test is to try and populate the slug field with a non-existent field. The expected exception looks like it should be raised if you tried to populate a non-existent field with a non-existent field. Therefore I think the expected value should be changed.

Changed 7 years ago by morty

Patch

comment:5 Changed 7 years ago by morty

  • Resolution set to fixed
  • Status changed from reopened to closed

My additions to this ticket are a duplicate of #9073. Sorry for this unnecessary posting. Closing again.

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