Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static file loading not working when using S3 static storage (DBTEMPLATES_MEDIA_PREFIX) #140

Open
jensjeflensje opened this issue Jun 5, 2023 · 0 comments

Comments

@jensjeflensje
Copy link

jensjeflensje commented Jun 5, 2023

I'm using django-dbtemplates with codemirror enabled inside my admin site. The problem is that the url it's trying to fetch codemirror.js from is incorrect. It tries to get http://<s3 endpoint>/dbtemplates/js/codemirror.js, which doesn't work (of course).

I found that I'm able to modify the place it's looking with DBTEMPLATES_MEDIA_PREFIX. Setting that to any value will result in a URL that's somewhat more correct (e.g. http://<s3 endpoint>/<bucket>/static/<media prefix value>/js/codemirror.js. Setting the variable to dbtemplates/ makes codemirror.js load. The real problem is that codemirror loads submodules itself. By default, it tries to load them at the current path (e.g. /admin/dbtemplates/template/add/undo.js). I fixed the submodule loading by setting DBTEMPLATES_MEDIA_PREFIX to /dbtemplates/. This unfortunately causes the codemirror.js file itself to fail.

I think the usage of DBTEMPLATES_MEDIA_PREFIX should be split up into 2 different variables: one that makes codemirror.js load, and one that is passed as a path to the codemirror instance in javascript (dbtemplates/admin.py:51). It should at least not have the exact same value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant