jazzband / django-polymorphic

Improved Django model inheritance with automatic downcasting
https://django-polymorphic.readthedocs.io
Other
1.63k stars 280 forks source link

Django polymorphic breaks admin site in setups with SCRIPT_NAME #448

Open pbrenna opened 4 years ago

pbrenna commented 4 years ago

The function get_model_perms in admin/childadmin.py can't resolve a match for the /admin/ path in setups where the wsgi parameter SCRIPT_NAME is set, because request.path seems to be prepended with the SCRIPT_NAME. An error 404 is returned instead of the admin homepage.

In my setup, using request.path_info instead works for me.

TristanSmithlib commented 4 years ago

I had the same issue. Worked fine on my local but when I deployed to staging I hit this issue. My site is set up to run in a non-root path. I was getting a 404 error after logging into the admin interface. Changing match = resolve(request.path) to match = resolve(request.path_info) in get_model_perms() in childadmin.py made the error go away.