Skip to content
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

ModelAdmin must define "search_fields", #1478

Open
ahcm opened this issue Jul 3, 2024 · 9 comments
Open

ModelAdmin must define "search_fields", #1478

ahcm opened this issue Jul 3, 2024 · 9 comments

Comments

@ahcm
Copy link

ahcm commented Jul 3, 2024

Hi,

upgrading from Django 2 I get:

$ ../venv/bin/python webportal/manage.py makemigrations
SystemCheckError: System check identified some issues:

ERRORS:
<class 'filer.admin.fileadmin.FileAdmin'>: (admin.E040) ModelAdmin must define "search_fields", because it's referenced by FileAdmin.autocomplete_fields.
<class 'filer.admin.folderadmin.FolderAdmin'>: (admin.E040) ModelAdmin must define "search_fields", because it's referenced by FolderAdmin.autocomplete_fields.
<class 'filer.admin.imageadmin.ImageAdmin'>: (admin.E040) ModelAdmin must define "search_fields", because it's referenced by ImageAdmin.autocomplete_fields.

These seem to define search_fields though.

Thanks !

Best
Andreas

@fsbraun
Copy link
Member

fsbraun commented Jul 3, 2024

@ahcm I cannot reproduce this. Can you give some version info?

@ahcm
Copy link
Author

ahcm commented Jul 4, 2024

I can fix it by adding a value to search_fields to ModelAdmin in django.contrib.admin.options.
Changing search_fields = () to search_fields=('foo',).

Python 3.11.2
django-filer 3.1.3
django 5.0.6

@fsbraun
Copy link
Member

fsbraun commented Jul 5, 2024

Any other packages updated that might interfere with the admin?

@ahcm
Copy link
Author

ahcm commented Jul 5, 2024

Installed apps are plenty:

INSTALLED_APPS = [
# added below 1 line for the accounts app
'accounts.apps.AccountsConfig',
# added below 1 line for the contact app
'contact.apps.ContactConfig',
# added below 1 line for the observations app
'observations.apps.ObservationsConfig',
# added below 1 line for the surveys app
'surveys.apps.SurveysConfig',
# added below 1 line for the pages app
'pages.apps.PagesConfig',
# added below 1 line for the map app
'map.apps.MapConfig',
# added below 1 line for the lexicon app
'lexicon.apps.LexiconConfig',
# added below 1 line for the wiki app
'wiki.apps.WikiConfig',
# added below 1 line for the offline interface
'offline.apps.OfflineConfig',
# added below 1 line for the news app
'news.apps.NewsConfig',
# added below 1 line for the messenger app
'messenger.apps.MessengerConfig',
# added below 1 line for the api interface
'api.apps.ApiConfig',
# added below 1 line for newsletter app
'newsletter',
# added below 5 lines for Django CMS
'django.contrib.sites',
'cms',
'menus',
'treebeard',
'djangocms_admin_style',
# added below 6 lines for Django CMS
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'djangocms_text_ckeditor',
'djangocms_link',
'djangocms_file',
'djangocms_picture',
'djangocms_video',
'djangocms_googlemap',
'djangocms_snippet',
'djangocms_style',
'djangocms_column',
'djangocms_icon',
# added below 15 lines for Django CMS Bootstrap 4
'djangocms_bootstrap4',
'djangocms_bootstrap4.contrib.bootstrap4_alerts',
'djangocms_bootstrap4.contrib.bootstrap4_badge',
'djangocms_bootstrap4.contrib.bootstrap4_card',
'djangocms_bootstrap4.contrib.bootstrap4_carousel',
'djangocms_bootstrap4.contrib.bootstrap4_collapse',
'djangocms_bootstrap4.contrib.bootstrap4_content',
'djangocms_bootstrap4.contrib.bootstrap4_grid',
'djangocms_bootstrap4.contrib.bootstrap4_jumbotron',
'djangocms_bootstrap4.contrib.bootstrap4_link',
'djangocms_bootstrap4.contrib.bootstrap4_listgroup',
'djangocms_bootstrap4.contrib.bootstrap4_media',
'djangocms_bootstrap4.contrib.bootstrap4_picture',
'djangocms_bootstrap4.contrib.bootstrap4_tabs',
'djangocms_bootstrap4.contrib.bootstrap4_utilities',
# geo-django gis functionality
'django.contrib.gis',
# added below 1 line to enable multiple selection https://github.com/goinnn/django-multiselectfield
'multiselectfield',
# added below 1 line for crispy forms from Bootstrap https://github.com/django-crispy-forms/django-crispy-forms
'crispy_forms',
# added below 1 line for adding captcha on the contact form captcha https://github.com/mbi/django-simple-captcha
'captcha',
# added below 2 lines for REST API
'rest_framework',
'rest_framework.authtoken',
# added below 1 line for newsletter subscription https://github.com/matthiask/django-newsletter-subscription
'newsletter_subscription',
# added below 1 line for newsletter subscription https://github.com/matthiask/towel/
'towel',
# added below 1 line for pwa https://github.com/silviolleite/django-pwa
'pwa',
# added below 14 lines for Django CMS
'sekizai',
'easy_thumbnails',
'filer',
'mptt',
# added below 1 line for adding avatar https://github.com/grantmcconnaughey/django-avatar
'avatar',

@sasikumar1978k
Copy link

ERRORS:
<class 'filer.admin.fileadmin.FileAdmin'>: (admin.E040) ModelAdmin must define "search_fields", because it's referenced by FileAdmin.autocomplete_fields.
<class 'filer.admin.folderadmin.FolderAdmin'>: (admin.E040) ModelAdmin must define "search_fields", because it's referenced by FolderAdmin.autocomplete_fields.
<class 'filer.admin.imageadmin.ImageAdmin'>: (admin.E040) ModelAdmin must define "search_fields", because it's referenced by ImageAdmin.autocomplete_fields.
<class 'filer.admin.permissionadmin.PermissionAdmin'>: (admin.E040) ModelAdmin must define "search_fields", because it's referenced by PermissionAdmin.autocomplete_fields.

@fsbraun
Copy link
Member

fsbraun commented Aug 9, 2024

Yes, filer does define them:

Some other code in your projects might be tempering with this.

Have you tried to open a shell (./manage.py shell) and do this?

In[1]: from filer.adminfileadmin import FileAdmin
In[2]: FileAdmin.search_fields

Copy link

stale bot commented Nov 9, 2024

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.

@stale stale bot added the stale label Nov 9, 2024
@rzwink
Copy link

rzwink commented Nov 25, 2024

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.

@stale stale bot removed the stale label Nov 25, 2024
@fsbraun
Copy link
Member

fsbraun commented Nov 25, 2024

@rzwink Thanks for the explanation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants