django-cms / django-filer

File and Image Management Application for django
https://django-filer.readthedocs.io/
Other
1.76k stars 577 forks source link

ModelAdmin must define "search_fields", #1478

Open ahcm opened 3 months ago

ahcm commented 3 months ago

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 commented 3 months ago

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

ahcm commented 3 months ago

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 commented 3 months ago

Any other packages updated that might interfere with the admin?

ahcm commented 3 months ago

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 commented 1 month ago

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 commented 1 month ago

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