admin lookup_allowed incorrectly returns False for a nested reverse OneToOneField
Assume these 3 models in an app called foo
:
class Somebody(models.Model):
user = models.OneToOneField(AUTH_USER_MODEL)
class Profile(models.Model): # we want an admin for this and filter on related data!
who = models.OneToOneField(Somebody)
class ClientInfo(models.Model):
who = models.OneToOneField(Somebody)
filter_by_me_please = models.CharField(db_index=True, max_length=20, blank=True)
and this profile admin:
class ProfileAdmin(admin.ModelAdmin):
list_filter = ('who__clientinfo__filter_by_me_please', )
admin.site.register(Profile, ProfileAdmin)
I get this error
DisallowedModelAdminLookup at /admin/foo/profile/
Filtering by who__clientinfo__filter_by_me_please not allowed
on opening http://localhost:8000/admin/foo/profile/?who__clientinfo__filter_by_me_please=yay
The 3 lookup levels seem to be important to reproduce this.
Change History
(13)
Summary: |
admin lookup_allowed returns False for a filter which is in list_filter → admin lookup_allowed incorrectly returns False for a nested reverse OneToOneField
|
Triage Stage: |
Unreviewed → Accepted
|
Owner: |
changed from nobody to Mariusz Felisiak
|
Status: |
new → assigned
|
Owner: |
changed from Mariusz Felisiak to Tobias McNulty
|
Owner: |
Tobias McNulty removed
|
Status: |
assigned → new
|
Owner: |
set to Mariusz Felisiak
|
Patch needs improvement: |
set
|
Status: |
new → assigned
|
Patch needs improvement: |
unset
|
Patch needs improvement: |
set
|
Has patch: |
unset
|
Owner: |
Mariusz Felisiak removed
|
Patch needs improvement: |
unset
|
Status: |
assigned → new
|
Cc: |
desecho@… added
|
Version: |
1.10 → master
|
Owner: |
set to Tim Graham <timograham@…>
|
Resolution: |
→ fixed
|
Status: |
new → closed
|
Reproduced at a4e9e834e3dfc8d5a024a78c765f193105d41a48.