I’d like to be able to search user profiles by username in the Django admin. Essentially, in admin.py, I’d be doing something like:
class UserProfileAdmin(admin.ModelAdmin):
search_fields = ['username']
But this won’t work since user is a foreign key in the my usual user profile set up.
Is there a quick way to achieve this without having to add a username field to my UserProfile model?
This should do what you want:
assuming the name of your field that is foreignkey is
user