django-cms / django-filer

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

manage.py migrate giving errors for filer's FolderAdmin/PermissionAdmin #1347

Closed heemayl closed 1 year ago

heemayl commented 1 year ago

I'm trying to follow the official guide to install django-cms: https://docs.django-cms.org/en/latest/how_to/install.html

I installed django-filer as a dependency and updated the relevant settings; I didn't do anything extra apart from what's mentioned in the doc.

Afterward, when I try to run python manage.py migrate filer, I'm getting the following errors:

SystemCheckError: System check identified some issues:

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

I tried to play with different versions but to no avail. Here are my relevant installed packages:

% pip freeze | grep -i django
Django==3.2.8
django-blacklist==0.6.1
django-classy-tags==4.0.0
django-cms==3.11.3
django-crispy-forms==1.13.0
django-extra-views==0.14.0
django-factory-boy==1.0.0
django-filer==2.2.4  # <<<<<------
django-formtools==2.3
django-funky-sheets==0.2.0
django-heroku==0.3.1
django-import-data==0.4.2
django-import-export==2.6.1
django-js-asset==2.0.0
django-mptt==0.14.0
django-otp==1.1.1
django-phonenumber-field==5.2.0
django-polymorphic==3.0.0
django-recaptcha==3.0.0
django-sekizai==4.1.0
django-slack==5.17.6
django-treebeard==4.4
django-two-factor-auth==1.13.1
django-widget-tweaks==1.4.8
djangocms-admin-style==3.2.4
djangocms-attributes-field==3.0.0
djangocms-file==3.0.0
djangocms-googlemap==2.0.0
djangocms-link==3.1.1
djangocms-picture==4.0.0
djangocms-snippet==3.1.0
djangocms-style==3.0.0
djangocms-text-ckeditor==5.1.2
djangocms-video==3.0.0

FWIW, I'm running Linux Mint 21 (derivative of Ubuntu 22.04).

Please let me know if you need any more info. Thanks.

heemayl commented 1 year ago

After going through the relevant source codes of django-filer and django-admin, and adding a debugger here on Django admin checks, found and fix the issue finally. I have a custom User model (for using email as the USERNAME_FILED and other stuff) but was using the default ModelAdmin (UserAdmin) for that causing the problem. To fix this, I've created a custom admin for the User model (inheriting from UserAdmin) and set correct values for attributes list_display and ordering (as they point to username in UserAdmin).

Given the misleading nature of the error messages, I'm not sure if it's worth adding a note on the django-filer/django-cms doc somewhere regarding the custom User model and ModelAdmin/UserAdmin.