Closed toracle closed 4 years ago
Previous versions of Django (1.9-1.11) use the same logic, so STATIC_URL should be ommited.
I confirm STATIC_URL should be removed. It doesn't work with external file storage backend (example: s3). I need to patch with
from django_json_widget.widgets import JSONEditorWidget
class JSONEditorWidget(JSONEditorWidget):
"""
Override media infos ith compliant django style
Wait for https://github.com/jmrivas86/django-json-widget/pull/23 merge
"""
class Media(JSONEditorWidget.Media):
css = {'all': ('dist/jsoneditor.min.css',)}
js = ('dist/jsoneditor.min.js',)
I close this PR because is solved in #30
I had a problem with asset URL, and inspected into it.
css and js property of django Media class is rendered by render_js and render_css method.
When look into that method, it calls absolute_path method to make a path absolute, and absolute_path calls static function, and it calls StaticNode.handle_simple method.
And, this
handle_simple
method do the same things you do, turn a path to absolute one withstorage.url()
.So, default django Media logic act like this:
django.contrib.staticfiles
app is installed, get astaticfile_storage
which is defined bysettings.STATICFILES_STORAGE
value, and usestorage.url(path)
to convert it to absolute.So, I think we can simply to remove any URL prefix and using a relative path would works well.