Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#20865 closed Bug (fixed)

admin raw_id_fields does not call value in limit_choices_to

Reported by: Collin Anderson Owned by: nobody
Component: contrib.admin Version: 1.6-beta-1
Severity: Normal Keywords:
Cc: Collin Anderson Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The docs show that limit_choices_to works with callables:
https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ForeignKey.limit_choices_to

However, the raw_id_fields widget does not handle this correctly, and it generates a url like so:
/admin/auth/user/?last_login__lte=%3Cbuilt-in%20method%20today%20of%20type%20object%20at%200xb72cd440%3E

As far as I can tell, this has never worked correctly. I have a simple app that demonstrates the problem:
https://github.com/collinanderson/limit_choices_to/commit/8e30de93dea1908ae363b8556e3f89d36b031e79

Change History (6)

comment:1 by Collin Anderson, 11 years ago

Has patch: set
Needs tests: set
Version: master1.6-beta-1

I realize that we're discussing a new api for limit_choices_to, but in the meantime this should fix it:
https://github.com/django/django/pull/1442

comment:2 by Tim Graham, 11 years ago

Triage Stage: UnreviewedAccepted

comment:3 by Collin Anderson, 11 years ago

Needs tests: unset

pull request now has a test https://github.com/django/django/pull/1442

comment:4 by loic84, 11 years ago

Triage Stage: AcceptedReady for checkin

Looks good to me.

comment:5 by Tim Graham <timograham@…>, 11 years ago

Resolution: fixed
Status: newclosed

In d53e574676ba0809394017f1f3a5bc24512e5bed:

Fixed #20865 -- Fixed raw_id_fields to work with callable limit_choices_to.

comment:6 by Tim Graham <timograham@…>, 11 years ago

In e3e0cf8a0f75ae18bc401182bfbdea2c27bb0244:

[1.6.x] Fixed #20865 -- Fixed raw_id_fields to work with callable limit_choices_to.

Backport of d53e574676 from master

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