[Django] #26979: Using an admin.RelatedOnlyFieldListFilter in admin does not working if a type of a field is ForeignKey and value to_field is not pk (in my case it is UUID).

37 views
Skip to first unread message

Django

unread,
Aug 1, 2016, 12:11:32 PM8/1/16
to django-...@googlegroups.com
#26979: Using an admin.RelatedOnlyFieldListFilter in admin does not working if a
type of a field is ForeignKey and value to_field is not pk (in my case it
is UUID).
-------------------------------+---------------------------------------
Reporter: setivolkylany | Owner: nobody
Type: Uncategorized | Status: new
Component: contrib.admin | Version: 1.9
Severity: Normal | Keywords: Admin, ForeignKey, models
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+---------------------------------------
'''a field of a model "User"'''


{{{
level = models.ForeignKey(
'UserLevel',
verbose_name='Level',
related_name='users',
default=UserLevel.CHOICES_LEVEL.regular,
to_field='name',
on_delete=models.PROTECT,
)
}}}


an all code of a models.py is here http://dpaste.com/3SC68RK

'''a list_filter in a class AdminUser'''


{{{
list_filter = [
('level', admin.RelatedOnlyFieldListFilter), # does not working
since UUID not accetabled
'is_superuser',
ListFilterLastLogin,
'date_joined',
]
}}}


an all code of a admin.py is here http://dpaste.com/0R0KPR9

--
Ticket URL: <https://code.djangoproject.com/ticket/26979>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Aug 1, 2016, 7:50:56 PM8/1/16
to django-...@googlegroups.com
#26979: Using an admin.RelatedOnlyFieldListFilter in admin does not working if a
type of a field is ForeignKey and value to_field is not pk (in my case it
is UUID).
-------------------------------------+-------------------------------------

Reporter: setivolkylany | Owner: nobody
Type: Uncategorized | Status: new
Component: contrib.admin | Version: 1.9
Severity: Normal | Resolution:
Keywords: Admin, ForeignKey, | Triage Stage:
models | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by skyjur):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

Seems to be fixed in 1.10.
https://code.djangoproject.com/ticket/25606
https://github.com/django/django/commit/815f4d206dfea41bdff167283c2cac43a71524ac

--
Ticket URL: <https://code.djangoproject.com/ticket/26979#comment:1>

Django

unread,
Aug 2, 2016, 3:27:04 PM8/2/16
to django-...@googlegroups.com
#26979: Using an admin.RelatedOnlyFieldListFilter in admin does not working if a
type of a field is ForeignKey and value to_field is not pk (in my case it
is UUID).
-------------------------------------+-------------------------------------
Reporter: setivolkylany | Owner: nobody
Type: Bug | Status: closed
Component: contrib.admin | Version: 1.9
Severity: Normal | Resolution: needsinfo

Keywords: Admin, ForeignKey, | Triage Stage:
models | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* status: new => closed
* type: Uncategorized => Bug
* resolution: => needsinfo


Comment:

What's the error? I can't reproduce a crash in 1.10, 1.9, or 1.8 but maybe
I didn't reproduce it correctly. If you can put together a simplified
sample project without any third-party dependencies, that makes the issue
much easier to triage.

--
Ticket URL: <https://code.djangoproject.com/ticket/26979#comment:2>

Django

unread,
Aug 30, 2016, 6:10:09 AM8/30/16
to django-...@googlegroups.com
#26979: Using an admin.RelatedOnlyFieldListFilter in admin does not working if a
type of a field is ForeignKey and value to_field is not pk (in my case it
is UUID).
-------------------------------------+-------------------------------------
Reporter: setivolkylany | Owner: nobody
Type: Bug | Status: closed
Component: contrib.admin | Version: 1.9

Severity: Normal | Resolution: needsinfo
Keywords: Admin, ForeignKey, | Triage Stage:
models | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by setivolkylany):

Replying to [comment:2 timgraham]:


> What's the error? I can't reproduce a crash in 1.10, 1.9, or 1.8 but
maybe I didn't reproduce it correctly. If you can put together a
simplified sample project without any third-party dependencies, that makes
the issue much easier to triage.

I created mini-project for the Django`s Team

https://bitbucket.org/setivolkylany/testdjango

If you need more details, do not be shy and contact with me

--
Ticket URL: <https://code.djangoproject.com/ticket/26979#comment:3>

Django

unread,
Aug 30, 2016, 8:40:07 AM8/30/16
to django-...@googlegroups.com
#26979: Using an admin.RelatedOnlyFieldListFilter in admin does not working if a
type of a field is ForeignKey and value to_field is not pk (in my case it
is UUID).
-------------------------------------+-------------------------------------
Reporter: setivolkylany | Owner: nobody
Type: Bug | Status: closed
Component: contrib.admin | Version: 1.9

Severity: Normal | Resolution: needsinfo
Keywords: Admin, ForeignKey, | Triage Stage:
models | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by timgraham):

After 815f4d206dfea41bdff167283c2cac43a71524ac, the sample project shows
"Cannot find 'comment' on Utility object, 'comment' is an invalid
parameter to prefetch_related()".

--
Ticket URL: <https://code.djangoproject.com/ticket/26979#comment:4>

Django

unread,
Aug 30, 2016, 9:19:09 AM8/30/16
to django-...@googlegroups.com
#26979: Using an admin.RelatedOnlyFieldListFilter in admin does not working if a
type of a field is ForeignKey and value to_field is not pk (in my case it
is UUID).
-------------------------------------+-------------------------------------
Reporter: setivolkylany | Owner: nobody
Type: Bug | Status: closed
Component: contrib.admin | Version: 1.9

Severity: Normal | Resolution: needsinfo
Keywords: Admin, ForeignKey, | Triage Stage:
models | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by setivolkylany):

Replying to [comment:4 timgraham]:


> After 815f4d206dfea41bdff167283c2cac43a71524ac, the sample project shows
"Cannot find 'comment' on Utility object, 'comment' is an invalid
parameter to prefetch_related()".

Sorry, but this commit related with a Django`s version 1.10, I am using
the 1.9.7 (if you see requirements.txt).

The problem is in a field models.UUIDField, because with a field
models.AutoField() all working properly (I am tested it)

Thus, please explain me, how "Added support for "__" lookup in
RelatedOnlyFieldList" is related with UUIDField

Second, I had mistake in code (I corrected it in new commit)

Instead of

{{{
qs = qs.prefetch_related('comment')
}}}

must be

{{{
qs = qs.prefetch_related('comments')
}}}


Thirdly
In real projects I am using PostgreSQL, no SQLite. But, I think it is not
have sense for this problem.

--
Ticket URL: <https://code.djangoproject.com/ticket/26979#comment:5>

Django

unread,
Aug 30, 2016, 9:36:42 AM8/30/16
to django-...@googlegroups.com
#26979: Using an admin.RelatedOnlyFieldListFilter in admin does not working if a
type of a field is ForeignKey and value to_field is not pk (in my case it
is UUID).
-------------------------------------+-------------------------------------
Reporter: setivolkylany | Owner: nobody
Type: Bug | Status: closed
Component: contrib.admin | Version: 1.9
Severity: Normal | Resolution: fixed

Keywords: Admin, ForeignKey, | Triage Stage:
models | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by timgraham):

* resolution: needsinfo => fixed


Comment:

As far as I can tell this issue is fixed in Django 1.10 by the commit I
mentioned. Per our [https://docs.djangoproject.com/en/dev/internals
/release-process/#supported-versions supported versions policy], Django
1.9.x is receiving only security and data loss fixes.

--
Ticket URL: <https://code.djangoproject.com/ticket/26979#comment:6>

Django

unread,
Aug 30, 2016, 11:37:15 AM8/30/16
to django-...@googlegroups.com
#26979: Using an admin.RelatedOnlyFieldListFilter in admin does not working if a
type of a field is ForeignKey and value to_field is not pk (in my case it
is UUID).
-------------------------------------+-------------------------------------
Reporter: setivolkylany | Owner: nobody
Type: Bug | Status: closed
Component: contrib.admin | Version: 1.9

Severity: Normal | Resolution: fixed
Keywords: Admin, ForeignKey, | Triage Stage:
models | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by setivolkylany):

Replying to [comment:6 timgraham]:


> As far as I can tell this issue is fixed in Django 1.10 by the commit I
mentioned. Per our [https://docs.djangoproject.com/en/dev/internals
/release-process/#supported-versions supported versions policy], Django
1.9.x is receiving only security and data loss fixes.

Thus it is bug in the Django 1.9.7 and it must be change status
from
#26979 closed Bug (fixed)
to
#26979 open Bug (unfixed)

Are you make it?

Other developers must be know about this problem.

--
Ticket URL: <https://code.djangoproject.com/ticket/26979#comment:7>

Django

unread,
Aug 30, 2016, 11:54:50 AM8/30/16
to django-...@googlegroups.com
#26979: Using an admin.RelatedOnlyFieldListFilter in admin does not working if a
type of a field is ForeignKey and value to_field is not pk (in my case it
is UUID).
-------------------------------------+-------------------------------------
Reporter: setivolkylany | Owner: nobody
Type: Bug | Status: closed
Component: contrib.admin | Version: 1.9

Severity: Normal | Resolution: fixed
Keywords: Admin, ForeignKey, | Triage Stage:
models | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by timgraham):

There isn't a ticket status for unfixed bugs in older version of Django.
"Fixed" simply means "fixed in some version of Django."

--
Ticket URL: <https://code.djangoproject.com/ticket/26979#comment:8>

Reply all
Reply to author
Forward
0 new messages