Search code examples
pythondjangodjango-smart-selects

python django smart-selects is not working properly


I have install django-smart-selects but when i add the url in the urls.py

url(r'^chaining/', include('smart_selects.urls')),

when i run my application after this i got this error

from django.utils.encoding import force_text ImportError: cannot import name 'force_text' from 'django.utils.encoding'

so here in django.utils.encoding I didn't find any import force_text so I change it to force_str.

I am using django 4.0


Solution

  • In your system libraries, edit this files:

    • .../smart_selects/form_fields.py
    • .../smart_selects/utils.py
    • .../smart_selects/widgets.py

    change: force_text. to: force_str

    Then, edit this file:

    • .../smart_selects/urls.py

    change: from django.conf.urls import url to: from django.urls import re_path change: url(... to: re_path(...

    in your project folder, edit urls.py

    from django.urls import include, path, re_path

    urlpatterns = [ ... re_path(r'^chaining/', include('smart_selects.urls')), ... ]