#35029: DisallowedModelAdminLookup for uuid field
-------------------------------------+-------------------------------------
     Reporter:  James Lao            |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  contrib.admin        |                  Version:  5.0
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
  DisallowedModelAdminLookup, uuid   |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by James Lao):

 Seems like this issue is not limited to UUID but to any field other than
 AutoField used as id. Maybe we should revert this change?

 The difference is in django/contrib/admin/options.py  => BaseModelAdmin =>
 lookup_allowed

 in 4.2.8

 {{{
         for part in lookup.split(LOOKUP_SEP):
             try:
                 field = model._meta.get_field(part)
             except FieldDoesNotExist:
                 # Lookups on nonexistent fields are ok, since they're
 ignored
                 # later.
                 break
             # It is allowed to filter on values that would be found from
 local
             # model anyways. For example, if you filter on
 employee__department__id,
             # then the id value would be found already from
 employee__department_id.
             if not prev_field or (
                 prev_field.is_relation
                 and field not in prev_field.path_infos[-1].target_fields
             ):
                 relation_parts.append(part)
             if not getattr(field, "path_infos", None):
                 # This is not a relational field, so further parts
                 # must be transforms.
                 break
             prev_field = field
             model = field.path_infos[-1].to_opts.model
 }}}

 In 5.0.0


 {{{
         for part in lookup.split(LOOKUP_SEP):
             try:
                 field = model._meta.get_field(part)
             except FieldDoesNotExist:
                 # Lookups on nonexistent fields are ok, since they're
 ignored
                 # later.
                 break
             if not prev_field or (
                 prev_field.is_relation
                 and field not in model._meta.parents.values()
                 and field is not model._meta.auto_field
                 and (
                     model._meta.auto_field is None
                     or part not in getattr(prev_field, "to_fields", [])
                 )
             ):
                 relation_parts.append(part)
             if not getattr(field, "path_infos", None):
                 # This is not a relational field, so further parts
                 # must be transforms.
                 break
             prev_field = field
             model = field.path_infos[-1].to_opts.model
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/35029#comment:2>
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/0107018c5b05cf0a-a4e937e8-4e61-4614-a99a-9450f5366cc4-000000%40eu-central-1.amazonses.com.

Reply via email to