Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#26979 closed Bug (fixed)

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).

Reported by: Seti Owned by: nobody
Component: contrib.admin Version: 1.9
Severity: Normal Keywords: Admin, ForeignKey, models
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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

Change History (8)

comment:2 by Tim Graham, 8 years ago

Resolution: needsinfo
Status: newclosed
Type: UncategorizedBug

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.

in reply to:  2 comment:3 by Seti, 8 years ago

Replying to 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

comment:4 by Tim Graham, 8 years ago

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

in reply to:  4 comment:5 by Seti, 8 years ago

Replying to 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.

comment:6 by Tim Graham, 8 years ago

Resolution: needsinfofixed

As far as I can tell this issue is fixed in Django 1.10 by the commit I mentioned. Per our supported versions policy, Django 1.9.x is receiving only security and data loss fixes.

in reply to:  6 comment:7 by Seti, 8 years ago

Replying to timgraham:

As far as I can tell this issue is fixed in Django 1.10 by the commit I mentioned. Per our 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.

comment:8 by Tim Graham, 8 years ago

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

Note: See TracTickets for help on using tickets.
Back to Top