User Search dependent on specific fields

Issue #14 closed
Peter Sanchez
repo owner created an issue

Currently the search view requires that the "User" model contains the following specific fields: username, email, first_name, and last_name. This is an issue for users with custom User models that don't contain on, or all, of those fields.

This should be a customizable setting.

Thanks to @Erik Telepovský for reporting this in Issue #13

Comments (12)

  1. Peter Sanchez reporter

    @Erik Telepovský What do you think of this solutions?

    Have a new setting, something like:


    This setting should be a list/tuple of the fields to search through on the "User" model.

    If not present, it will default to the following:

    • User.USERNAME_FIELD (or "username" if not present)
    • email
    • first_name
    • last_name

    Whatever fields are listed, the query will use __icontains when searching the field(s) given.

    Maybe it makes more sense to only search through User.USERNAME_FIELD (or "username" if not present) and not presume the other fields exist. I was thinking of keeping them by default for backwards compatibility.

    What do you think?

    @Marcel Chastain Do have any input on this?

  2. Peter Sanchez reporter


    My apologies. I haven't had a chance to touch this yet. Crazy busy at the moment. I'm trying to find the time, it's definitely in my todo list.


  3. Log in to comment