#35029 closed Bug (duplicate)
DisallowedModelAdminLookup for uuid field
Reported by: | James Lao | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admin | Version: | 5.0 |
Severity: | Normal | Keywords: | DisallowedModelAdminLookup, uuid |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
On Django 5.0 and MariaDB 11.0.4, 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
Change History (4)
comment:1 by , 12 months ago
Description: | modified (diff) |
---|
comment:2 by , 12 months ago
comment:3 by , 12 months ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Seems to be the same as #35020
comment:4 by , 12 months ago
Resolution: | fixed → duplicate |
---|
Note:
See TracTickets
for help on using tickets.
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
In 5.0.0