#35029: DisallowedModelAdminLookup for uuid field
-------------------------------------+-------------------------------------
               Reporter:  jameslao   |          Owner:  nobody
                   Type:  Bug        |         Status:  new
              Component:             |        Version:  5.0
  contrib.admin                      |       Keywords:
               Severity:  Normal     |  DisallowedModelAdminLookup, uuid
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 In Django 5.0, if we create a model with primary ID field with UUIDField,
 and another model referencing it, then in Django admin, if we create a
 filter of the second model with the first model, an error of
 DisallowedModelAdminLookup will be thrown.

 in models.py

 {{{
 from django.db import models
 import uuid

 # Create your models here.

 class Request(models.Model):
     id = models.UUIDField(primary_key=True, default=uuid.uuid4,
                           editable=False, verbose_name='Request ID')
     name = models.CharField(max_length=50, blank=True)


 class RequestItem(models.Model):
     request = models.ForeignKey(Request, on_delete=models.CASCADE,
 related_name='items')
     description = models.CharField(max_length=255, blank=True)
 }}}

 in admin.py


 {{{
 from . import models

 @admin.register(models.RequestItem)
 class RequestItemAdmin(admin.ModelAdmin):
     list_display = (
         'request',
     )
     list_filter = (
         'request',
     )


 @admin.register(models.Request)
 class RequestAdmin(admin.ModelAdmin):
     list_display = (
         'id', 'name'
     )
     list_filter = (
         'id',
     )

 }}}

 Then the filter of request in RequestItemAdmin will throw an error

 {{{
 DisallowedModelAdminLookup at /admin/uid/requestitem/
 Filtering by request__id__exact not allowed
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/35029>
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/0107018c5ab4fb2a-b9adb648-4aa2-44ac-b43c-890d3fd4bed0-000000%40eu-central-1.amazonses.com.

Reply via email to