Skip to content

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.
@lovelydinosaur
Copy link
Contributor

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.

@lovelydinosaur
Copy link
Contributor

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
Contributor

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