#35020: DisallowedModelAdminLookup for foreign key to non-AutoField primary key
------------------------------------------+------------------------
               Reporter:  Joshua Goodwin  |          Owner:  nobody
                   Type:  Bug             |         Status:  new
              Component:  contrib.admin   |        Version:  5.0
               Severity:  Normal          |       Keywords:
           Triage Stage:  Unreviewed      |      Has patch:  0
    Needs documentation:  0               |    Needs tests:  0
Patch needs improvement:  0               |  Easy pickings:  0
                  UI/UX:  0               |
------------------------------------------+------------------------
 I have a model whose primary key is not an AutoField, and another model
 with a foreign key pointing at that:

 {{{#!python
 class Country(models.Model):
     id = models.CharField(max_length=2, primary_key=True)


 class Place(models.Model):
     country = models.ForeignKey(Country, models.CASCADE)
 }}}

 And a ModelAdmin with this list_filter:

 {{{#!python
 @admin.register(models.Place)
 class PlaceAdmin(admin.ModelAdmin):
     list_filter = ["country"]
 }}}

 Since 45ecd9acca9b36093e274f47b6877a5f79108d9e, filtering places by
 country in the admin site raises
 `django.contrib.admin.exceptions.DisallowedModelAdminLookup: Filtering by
 country__id__exact not allowed`

-- 
Ticket URL: <https://code.djangoproject.com/ticket/35020>
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/0107018c3f0f85ad-3ab43c97-9a59-40e1-b113-8997034d9e0d-000000%40eu-central-1.amazonses.com.

Reply via email to