Skip to content

TokenAdmin: add 'user' to autocomplete_fields #6762

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 28, 2019

Conversation

jieter
Copy link
Contributor

@jieter jieter commented Jun 28, 2019

TokenAdmin is unusable with a big number of user records (in this case ~150k). Django 2.0 added the ModelAdmin.autocomplete_fields option to use select2 to provide a better user experience.

If support for django 1.11 is dropped, this change would make the TokenAdmin usable again.

TokenAdmin is unusable with a big number of user records (in this case ~150k). Django 2.0 added the [ModelAdmin.autocomplete_fields](https://docs.djangoproject.com/en/stable/ref/contrib/admin/#django.contrib.admin.ModelAdmin.autocomplete_fields) option to use select2 to provide a better user experience.

If support for django 1.11 is dropped, this change would make the `TokenAdmin` usable again.
@tomchristie
Copy link
Member

"If support for django 1.11 is dropped"

Presumably there's no reason we can't accept this change, without having to drop Django 1.11.

It should be a problem to set the "autocomplete_fields" attribute, even if it's not actually used right?

@jieter
Copy link
Contributor Author

jieter commented Jun 28, 2019

You are right, adding the option doesn't matter to django==1.11.

@tomchristie tomchristie merged commit cfd3ea0 into encode:master Jun 28, 2019
@jieter jieter deleted the patch-1 branch June 28, 2019 15:11
@sourcepirate
Copy link

sourcepirate commented Jul 15, 2019

This one broke the existing code.

ERRORS:
<class 'rest_framework.authtoken.admin.TokenAdmin'>: (admin.E040) ModelAdmin must define "search_fields", because it's referenced by TokenAdmin.autocomplete_fields.

When running django 2.2.3 with drf 3.10.0.
Do you think we can add user to search fields ?

@rpkilby
Copy link
Member

rpkilby commented Jul 15, 2019

Hi @sourcepirate, could you open a new issue to track this?

@sourcepirate
Copy link

Sure!

from django.contrib import admin
from .models import User


class UserAdmin(admin.ModelAdmin):

    search_fields = ("email",)


# Register your models here.
admin.site.register(User, UserAdmin)

I need to modify my admin.py to the above to avoid the error.

@tomchristie tomchristie mentioned this pull request Jul 17, 2019
pchiquet pushed a commit to pchiquet/django-rest-framework that referenced this pull request Nov 17, 2020
TokenAdmin is unusable with a big number of user records (in this case ~150k). Django 2.0 added the [ModelAdmin.autocomplete_fields](https://docs.djangoproject.com/en/stable/ref/contrib/admin/#django.contrib.admin.ModelAdmin.autocomplete_fields) option to use select2 to provide a better user experience.

If support for django 1.11 is dropped, this change would make the `TokenAdmin` usable again.
sigvef pushed a commit to sigvef/django-rest-framework that referenced this pull request Dec 3, 2022
TokenAdmin is unusable with a big number of user records (in this case ~150k). Django 2.0 added the [ModelAdmin.autocomplete_fields](https://docs.djangoproject.com/en/stable/ref/contrib/admin/#django.contrib.admin.ModelAdmin.autocomplete_fields) option to use select2 to provide a better user experience.

If support for django 1.11 is dropped, this change would make the `TokenAdmin` usable again.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants