You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you use a custom user that does not include first_name / last_name as a field, searching in the admin will error out as actor__first_name and actor__last_name are not valid fields.
I can think of a few options:
Unregister the admin using admin.site.unregister(LogEntry)
Subclass LogEntryAdmin, override search_fields
Register this new admin.
Or simply remove these fields from the built-in admin search_fields.
Or only add these to search if get_user_model + meta ensures they exist.
I generally avoid splitting up first name / last name these days, though I know Django defaults to this.
Let me know which option sounds reasonable and I'm happy to open a PR. Great project, saved me a lot of time. Thanks.
The text was updated successfully, but these errors were encountered:
silviogutierrez
changed the title
Document or remove first_name / last_name as a search in the admin
Document or remove first_name / last_name as a search in the admin for custom users
Feb 9, 2023
@silviogutierrez, the option to ensure that first_name & last_name fields exists makes the most sense to me. I think we can define get_search_fields method on LogEntryAdmin which will inspect the user model and exclude any of the two fields if they are not defined.
If you use a custom user that does not include
first_name
/last_name
as a field, searching in the admin will error out asactor__first_name
andactor__last_name
are not valid fields.I can think of a few options:
admin.site.unregister(LogEntry)
LogEntryAdmin
, overridesearch_fields
Or simply remove these fields from the built-in admin
search_fields
.Or only add these to search if
get_user_model
+ meta ensures they exist.I generally avoid splitting up first name / last name these days, though I know Django defaults to this.
Let me know which option sounds reasonable and I'm happy to open a PR. Great project, saved me a lot of time. Thanks.
The text was updated successfully, but these errors were encountered: