django-smart-selects icon indicating copy to clipboard operation
django-smart-selects copied to clipboard

Actually doesnt support django version 4

Open DARKDEYMON opened this issue 3 years ago • 11 comments

Actually doesnt support django version 4 in pip

DARKDEYMON avatar Dec 17 '21 18:12 DARKDEYMON

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.

luigi370 avatar Dec 24 '21 12:12 luigi370

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

sdsy888 avatar Dec 29 '21 04:12 sdsy888

Thanks, man you made my life easy

xs2hamzashah avatar Feb 24 '22 18:02 xs2hamzashah

Same issue here.

Audiopolis avatar Apr 04 '22 16:04 Audiopolis

already updated or not?

facundopadilla avatar Apr 11 '22 00:04 facundopadilla

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.

Audiopolis avatar Apr 11 '22 01:04 Audiopolis

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.

facundopadilla avatar Apr 11 '22 02:04 facundopadilla

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.)

pareshpandit avatar Jun 10 '22 17:06 pareshpandit

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?

iserranoe avatar Jul 13 '22 14:07 iserranoe

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')),
]

kfirufk avatar Aug 16 '22 17:08 kfirufk

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

amegianeg avatar Jan 25 '24 11:01 amegianeg