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.1k stars 348 forks source link

It doesn't work when I change the admin path #338

Open admmello opened 2 years ago

admmello commented 2 years ago

when I change the admin URL from

urlpatterns = [
    path('admin/', admin.site.urls),
    path('chaining/', include('smart_selects.urls')),
....

to

urlpatterns = [
    path('', admin.site.urls),
    path('chaining/', include('smart_selects.urls')),
....

django-smart-selects stops working. How can I fix this?

pareshpandit commented 2 years ago

Hi @admmello : I know this question is now old, but since it was unanswered--there goes nothing :

It is strange, and I can not fathom with my limited knowledge of either of the projects at this point (i.e. your proj, and this git).

However, if it indeed is, as you seem to indicate it to be, I would take a wild guess and say that keeping both paths should resolve it ; kindly try:

urlpatterns = [ path('admin/', admin.site.urls), path('', admin.site.urls), path('chaining/', include('smart_selects.urls')), ....

admmello commented 2 years ago

I found another way to solve this, I created a view of path ('', home, name = 'home'), and inside the home.html I put an empty HTML with a meta to redirect automatically

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="Refresh" content="0; url={% url 'admin:login' %}" />
    <title>Title</title>
</head>
<body>
</body>
</html>
jonimke commented 1 year ago

Hey @admmello, I had the same problem and was able to solve it by just changing the order in my urlpattern.

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