-
Notifications
You must be signed in to change notification settings - Fork 413
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
Remove first_name / last_name from admin if missing from model #512
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #512 +/- ##
==========================================
+ Coverage 94.22% 94.24% +0.01%
==========================================
Files 30 30
Lines 900 903 +3
==========================================
+ Hits 848 851 +3
Misses 52 52
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@silviogutierrez Thanks for this path. As I mention in the issue, overriding the |
f"actor__{get_user_model().USERNAME_FIELD}", | ||
] | ||
f"actor__{user_model.USERNAME_FIELD}", | ||
] + ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about something like the following, which adds whichever field is available, handling the case where either fist_name
or last_name
do actually exist
search_fields = [
"timestamp",
"object_repr",
"changes",
f"actor__{get_user_model().USERNAME_FIELD}",
] + [f"actor__{f.name}" for f in get_user_model()._meta.get_fields() if f.name in ["first_name", "last_name"]]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is better because includes whatever fields that are available.
Feel free to create a new PR with tests and changelog
Hi. Any progress planned for this issue? |
The approach of this PR should be changed. BTW, you can create your custom admin inherited from |
Closes #509
This is a "static" approach, which I think is better than overriding
get_search_fields
. I believe theget_*
methods are for truly dynamic behavior (based on the request, the current user, etc). With this, admin checks will still apply (though not particularly useful).