8000 Do not use select field to display list of users by ticosax · Pull Request #3830 · encode/django-rest-framework · GitHub
[go: up one dir, main page]

Skip to content

Do not use select field to display list of users #3830

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

Closed
wants to merge 1 commit into from

Conversation

ticosax
Copy link
Contributor
@ticosax ticosax commented Jan 14, 2016

When generating authtoken from admin interface, the defaut html form
is unusable in presence of a large user base.

When generating authtoken from admin interface, the defaut html form
is unusable in presence of a large user base.
@tomchristie
Copy link
Member

Fair enough. I'm not really sure which of the two cases we should optimize this for. Using raw_ids makes sense if that'll allow it to be usable in all cases, but it's a shame that it'll impact users who don't require this too. Could you include screenshots of how the admin appears in each case. Also perhaps a note on this issue how to monkeypatch/tweak this for users who want the default case? That way we can consider documenting how to most easily customize the admin display for each case.

@ticosax
Copy link
Contributor Author
ticosax commented Jan 14, 2016

raw_id_fields works in 4 steps.

  1. you see an empty text field
    drf-admin-auth-token
  2. you click on the magnifying glass.
  3. you are redirected to a list view of users, where you can filter( /admin/auth/user/ ). then you select your user by clinking on its row.
  4. you are redirected to the authtoken creation form, with the user field, pre-field with user's pk you just selected.

To be honest raw_id_fields works better with autocomplete.

In other hand, I tried your suggestion, we can monkey patch the Admin class, in our project. It works also.

admin.py

from rest_framework.authtoken.admin import TokenAdmin

TokenAdmin.raw_id_fields = ('user',)

then it is a matter of documenting it.

@tomchristie
Copy link
Member

then it is a matter of documenting it.

I think I'd probably prefer that, rather than changing the existing behavior.

@ticosax
Copy link
Contributor Author
ticosax commented Jan 14, 2016

ok, thanks for the feedback.

@jpadilla
Copy link
Member

How much I wish raw_id_fields was used by default in Django.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0