#34015: "Related Field got invalid lookup: startswith" on CharField ForeignKey
-------------------------------------+-------------------------------------
     Reporter:  Thomas               |                    Owner:  nobody
         Type:  New feature          |                   Status:  new
    Component:  Database layer       |                  Version:  4.1
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  ORM lookup           |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

 * type:  Bug => New feature


Comment:

 Thanks for the report. Django 4.2
 (cd1afd553f9c175ebccfc0f50e72b43b9604bd97) allows
 
[https://docs.djangoproject.com/en/dev/ref/models/lookups/#django.db.models.lookups.RegisterLookupMixin.register_lookup
 registering lookups per field instances], so you will be able to register
 `__startswith` for `parent_object_id`, e.g.
 {{{#!python
 parent_field = Child._meta.get_field("parent_object_id")
 with register_lookup(parent_field, StartsWith):
     Child.objects.filter(parent_object_id__startswith='c')
 }}}

 Duplicate of #29799.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34015#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018344eeeb57-111032cf-8067-4780-9a02-5062b4fb0042-000000%40eu-central-1.amazonses.com.

Reply via email to