Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom lookup feature? #1739

Open
Pediatra opened this issue Oct 15, 2024 · 0 comments
Open

Custom lookup feature? #1739

Pediatra opened this issue Oct 15, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@Pediatra
Copy link

Pediatra commented Oct 15, 2024

I would like to request support for custom lookups in, similar to Django's implementation.

@fields.CharField.register_lookup
class MyCustomLookup(Lookup):
    lookup_name = 'my_custom'

    def as_sql(self, compiler, connection):
        lhs, lhs_params = compiler.compile(self.lhs)
        rhs, rhs_params = compiler.compile(self.rhs)
        params = lhs_params + rhs_params
        return '%s MY_OPERATOR %s' % (lhs, rhs), params

Model.filter(name__my_custom='test')

@Pediatra Pediatra reopened this Oct 15, 2024
@henadzit henadzit added the enhancement New feature or request label Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants