mlavin / django-selectable

Tools and widgets for using/creating auto-complete selection widgets using Django and jQuery UI.
http://django-selectable.readthedocs.io/en/latest/
BSD 2-Clause "Simplified" License
129 stars 64 forks source link

Django-selectable incompatible with Django 4.0 #221

Closed ArkieCoder closed 1 year ago

ArkieCoder commented 2 years ago

When using django-selectable with Django 4.0, the following error occurs on startup:

   File "/code/django_selectable/selectable/urls.py", line 1, in <module>
     from django.conf.urls import url
 ImportError: cannot import name 'url' from 'django.conf.urls' (/usr/local/lib/python3.10/site-packages/django/conf/urls/__init__.py)

This is due to the fact that django.conf.urls.url was finally removed from Django in 4.0 after being deprecated for some time in Django 3.x. More info here: https://forum.djangoproject.com/t/django-4-0-url-import-error/11065/5

I have found that this simple patch fixes this issue, and would like to submit it to the group for inclusion:

--- a/selectable/urls.py
+++ b/selectable/urls.py
@@ -1,8 +1,8 @@
-from django.conf.urls import url
+from django.urls import re_path

 from . import views

 urlpatterns = [
-    url(r'^(?P<lookup_name>[-\w]+)/$', views.get_lookup, name="selectable-lookup"),
+    re_path(r'^(?P<lookup_name>[-\w]+)/$', views.get_lookup, name="selectable-lookup"),
 ]
ArkieCoder commented 2 years ago

If you'd just like to use the patch above and you're working within Docker, you can add these lines to your Dockerfile to apply the patch to what is installed via pip3. This example assumes you have django-selectable in your requirements.txt, and that the above patch is stored in the file ./patches/selectable-urls-py.gitpatch relative to your Dockerfile.

RUN pip3 install -r requirements.txt
RUN pip3 show django-selectable | \
    grep "^Location: " | sed -e "s/^Location: //g" > /tmp/dsloc.txt
COPY ./patches/selectable-urls-py.gitpatch /tmp
RUN cp /tmp/selectable-urls-py.gitpatch `cat /tmp/dsloc.txt`
RUN cd `cat /tmp/dsloc.txt` && git apply selectable-urls-py.gitpatch

If you're not running via Docker, in your build process right after you install requirements using pip3, you can use something like this shell script:

#!/usr/bin/env bash
virtualenv /home/ubuntu/app/venv
source /home/ubuntu/app/venv/bin/activate
DSLOC=`pip3 show django-selectable | \
  grep "^Location: " | sed -e "s/^Location: //g"` 
cd $DSLOC && git apply /home/ubuntu/app/patches/selectable-urls-py.gitpatch

It should be noted that the patch above is a result of a git diff and that's why I'm using git apply to apply it, because patch requires some additional processing of git diffs in order to function properly.

luisperlaz commented 2 years ago

Are there plans to merge this #222? Is it that it's still pending for review, or simply there's no maintainer anymore? I'll be willing to help in any way to push this forward.

aitoehigie commented 1 year ago

Just wondering if there are any actively maintained alternatives to Django-Selectable that support Django 4.*?

domdinicola commented 1 year ago

released v1.4