jazzband / django-smart-selects

chained and grouped selects for django forms
https://django-smart-selects.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
1.12k stars 352 forks source link

Actually doesnt support django version 4 #339

Open DARKDEYMON opened 2 years ago

DARKDEYMON commented 2 years ago

Actually doesnt support django version 4 in pip

luigi370 commented 2 years ago

I got the same problem.. but if you install it from the repo like this (pipenv)

django-smart-selects = {editable = true, ref = "master", git = "https://github.com/jazzband/django-smart-selects.git"}

it works for me.

sdsy888 commented 2 years ago

same problem spotted.

For the self-saving solution, I have to change all the force_text to force_str like this:

try:
    from django.utils.encoding import force_text
except ImportError:
    from django.utils.encoding import force_str as force_text

and all the places using the url to this( because the url method has been removed in Django4.0):

try:
    from django.conf.urls.defaults import url
except ImportError:
    from django.urls import  re_path as url
xs2hamzashah commented 2 years ago

Thanks, man you made my life easy

Audiopolis commented 2 years ago

Same issue here.

facundopadilla commented 2 years ago

already updated or not?

Audiopolis commented 2 years ago

already updated or not?

Not that I can see unless you use custom models. My best options were to either not use Django v4 or not use django-smart-selects. Decided on Django v3.2 for now.

facundopadilla commented 2 years ago

ya actualizado o no?

No es que pueda verlo a menos que use modelos personalizados. Mis mejores opciones eran no usar Django v4 o no usar django-smart-selects. Decidí Django v3.2 por ahora.

I just did the same thing, downgraded to 3.1 and it works without problems.

pareshpandit commented 2 years ago

Confirmation / Update & Request

Indeed, I faced this too. Then, realised that pip seems to pull a really old repo, and the syntaxes therein are super deprecated.

Best advised to download the latest repo from GitHub, and use it instead. It works just fine with Django 4 & Python 3.10. [As for me, since I had already pulled the earlier one vide pip, I simply replaced the files, from a local download.]

Can the versioning not be forced to upgrade @ pip somehow? :) (Sorry, I am not very familiar with how things work out there, am a noob.)

iserranoe commented 2 years ago

same problem spotted.

For the self-saving solution, I have to change all the force_text to force_str like this:

try:
    from django.utils.encoding import force_text
except ImportError:
    from django.utils.encoding import force_str as force_text

and all the places using the url to this( because the url method has been removed in Django4.0):

try:
    from django.conf.urls.defaults import url
except ImportError:
    from django.urls import  re_path as url

Where should I include this code?

kfirufk commented 2 years ago

works amazing with django 4.1 for urls do this:

from django.contrib import admin
from django.urls import path, include, re_path

urlpatterns = [
    path('admin/', admin.site.urls),
    re_path(r'^chaining/', include('smart_selects.urls')),
]
amegianeg commented 8 months ago

Tried in a small PoC with Django 4.2.8 and Python 3.11 and seems to be working fine.