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 · 6 comments
Open

ModelAdmin must define "search_fields", #1478

ahcm opened this issue Jul 3, 2024 · 6 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
Sponsor 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
Sponsor 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
Sponsor 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

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

3 participants