Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#31305 closed Bug (duplicate)

FieldError when doing batch update from the list view.

Reported by: Ciske Boekelo Owned by: nobody
Component: contrib.admin Version: 2.1
Severity: Normal Keywords: FieldError annotation batch update admin
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I'm getting a FieldError when the following conditions are met:

  • I'm in the admin, looking at a list view
  • in the ModelAdmin, I've overridden get_queryset() to add an annotation (a Sum operation) before returning the queryset
  • *I've sorted the view by this annotation column.*
  • I have selected a few items
  • I perform a batch action
  • in the batch action I do a batch update with queryset.update()

I get this error:

Internal Server Error: /admin/.../

FieldError at /admin/.../
Cannot resolve keyword 'x' into field. Choices are: y, z, ...

Request Method: POST
Request URL: https://host.com/admin/.../?o=-6
Django Version: 2.1
Python Executable: /usr/bin/python3
Python Version: 3.6.9

Column -6 in the URL being the annotation column.

I do NOT get an error when all conditions are the same, except I haven't sorted by the annotation column.

Change History (2)

comment:1 by Mariusz Felisiak, 5 years ago

Resolution: duplicate
Status: newclosed
Summary: FieldError when doing batch update from the list viewFieldError when doing batch update from the list view.

Duplicate of #28897. Please provide a minimal (but complete, with models) example in the original ticket.

comment:2 by Ciske Boekelo, 5 years ago

I've tried for three hours to duplicate the bug in a sample project and I couldn't do it. It's more complicated than I described above. There's also a filter involved, but I don't know what the precise 'requirements' of the filter need to be.
Does anyone more acquainted with the django internals feel like debugging on my laptop via remote desktop?

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