-
Notifications
You must be signed in to change notification settings - Fork 582
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
Custom user model's ModelAdmin
must define "search_fields",
#1478
Comments
@ahcm I cannot reproduce this. Can you give some version info? |
I can fix it by adding a value to search_fields to ModelAdmin in django.contrib.admin.options. Python 3.11.2 |
Any other packages updated that might interfere with the admin? |
Installed apps are plenty: INSTALLED_APPS = [ |
ERRORS: |
Yes, filer does define them:
Some other code in your projects might be tempering with this. Have you tried to open a shell (
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
In case any one else has this error. My project has a custom User Model. I fixed this by adding search_fields to my customer User model admin. Essentially, this is not a problem with this project, but a field missing from my user model admin. |
@rzwink Thanks for the explanation! |
Hi. I am facing the same issue. If I add search_fields=('foo',) , it resolves the issue but it is not a good solution. Is there any other solutions to solve the issue? |
@anjanpa The only other solution I can think of is removing the auto complete if if user model's admin does not have Would you like to come up with a PR? |
ModelAdmin
must define "search_fields",
HI @fsbraun Thank you for acknowledging the problem. The problem occurred because I defined custom user model and didn't define search fields in the admin.py. When I added search_fields in admin.py: from django.contrib import admin This solved my problem. |
I'm also facing the same error.
I just added following in INSTALLED_APPS section
|
in your admin.py file did you create useradmin(admin.ModelAdmin) Also did you add search fields like this also, the user model I used is a custom model |
Great, Thanks @anjanpa , Following fix, fixed this issue for me.
This means if there is custom user, then we need to define |
no when you are using filer , it uses auto complete fields. And for autocomplete fields, search fields are necessary in the corresponding model. That's why we need to use ModelAdmin and write search fields. |
What do you think about doing something like this in FileAdmin to handle User admins without search_fields defined? Or even futher simplify it with just an error that User model admin needs search_fields defined.
|
Hi,
upgrading from Django 2 I get:
These seem to define search_fields though.
Thanks !
Best
Andreas
The text was updated successfully, but these errors were encountered: