Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#13556 closed (worksforme)

admin.exclude thinks that a m2m field that is missing from a modelform.

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

Description

This is a rather serious 1.1.2 regression. 1.1.1 worked (and still works) fine.

Trying to start the server raises:

File "[projroot]/src/[proj]/apps/accounts/admin.py" in <module>
  84. admin.site.register(models.UserProfile, UserProfile)
File "[projroot]/src/django/django/contrib/admin/sites.py" in register
  90.             validate(admin_class, model)
File "[projroot]/src/django/django/contrib/admin/validation.py" in validate
  25.     validate_base(cls, model)
File "[projroot]/src/django/django/contrib/admin/validation.py" in validate_base
  227.             check_formfield(cls, model, opts, 'exclude', field)
File "[projroot]/src/django/django/contrib/admin/validation.py" in check_formfield
  310.                 "is missing from the form." % (cls.__name__, label, field))
  
Exception Type: ImproperlyConfigured at /
Exception Value: 'UserProfile.exclude' refers to field 'tracked_tickers' that is missing from the form.

tracked_tickers is a basic m2m field on the UserProfile model.

Change History (3)

comment:1 Changed 5 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 this -- listing a ManyToManyField in exclude for a ModelAdmin works fine in my testing. So there has to be more to it than what's been posted but there is not enough detail here for me to have any clue what it might be.

comment:2 Changed 5 years ago by gabrielhurley

It may or may not be the case here, but I saw that type of error when I first started testing 1.2 and had models configured where I'd set editable = False on the field in the model definition and later tried to exclude that field elsewhere. In my case it was Django no longer swallowing an error that should have been raised before.

comment:3 Changed 5 years ago by SmileyChris

Works for me now too.

Seems that it was some stale *.pyc files left over from switching branches in-place causing problems. Deleting all the pyc files solved the problem (an existing test in admin_validation was failing too, so no new test was required).

Sorry for the noise, nothing to see here, carry on folks... :D

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