Opened 23 months ago

Last modified 10 months ago

#29799 assigned New feature

Allow registration and unregistration of lookups per field instances.

Reported by: Simon Charette Owned by: Can Sarıgöl
Component: Database layer (models, ORM) Version: master
Severity: Normal Keywords:
Cc: Sergey Fedoseev, Can Sarıgöl Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

Under certain circumstances it might be useful to register or unregister model field lookups on a per instance basis instead of a per class basis.

For example, it could be useful to disable costly lookups such as contains and icontains on some large table model CharFields without defining them using a CharField subclass to prevent them from being used in production. Similarly you might want to register or override a specific lookup for a third party app model field that doesn't allow swapping.

This was initially mentioned in #16187 which introduced this new lookup registration system.

https://code.djangoproject.com/ticket/16187#comment:14

Having the ability to hook a custom lookup to a given field instance would be really nice to have...

https://code.djangoproject.com/ticket/16187#comment:22

Add a way to register lookups to fields (I think either instances or classes is wanted behaviour).

But not discussed afterwhile. I believe class based registration was chosen because it was easier to implement but I agree that being able to register custom lookups per field instance would be good feature addition.

Change History (5)

comment:1 Changed 23 months ago by Carlton Gibson

Triage Stage: UnreviewedAccepted

Yes. Super.

comment:2 Changed 21 months ago by Sergey Fedoseev

Cc: Sergey Fedoseev added

comment:3 Changed 15 months ago by Can Sarıgöl

Cc: Can Sarıgöl added
Has patch: set

comment:4 Changed 10 months ago by Carlton Gibson

Needs documentation: set
Patch needs improvement: set

comment:5 Changed 10 months ago by Can Sarıgöl

Owner: changed from nobody to Can Sarıgöl
Status: newassigned
Note: See TracTickets for help on using tickets.
Back to Top