question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ReferenceError: Can't find variable: JSONEditor

See original GitHub issue
  • django-json-widget version: django-json-widget==0.2.0
  • Django version: Django==2.2.3
  • Python version: Python 3.7.3
  • Operating System: Ubuntu

Added the app in INSTALLED_APPS Added the widget in the form If i refresh the admin page, i get

[Error] ReferenceError: Can't find variable: JSONEditor
	(anonymous function) (change:208)
	Global Code (change:211)
[Error] ReferenceError: Can't find variable: JSONEditor
	(anonymous function) (change:231)
	Global Code (change:234)
        var editor = new JSONEditor(container, options);
        var json = {"a": "b"};
        editor.set(json);

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:2
  • Comments:7

github_iconTop GitHub Comments

1reaction
fedorbeetscommented, Jun 4, 2020

Using django-json-widget==1.0.1 Django==3.0.3 and Python 3.8.2

I still get the issue ReferenceError: JSONEditor is not defined. The above solution of creating a custom widget did not work for me.

I ofcourse added the app in INSTALLED_APPS and the widget to the form ala widgets = {'configuration': CustomJSONEditorWidget}

I had to add:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jsoneditor/5.13.2/jsoneditor.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/jsoneditor/5.13.2/jsoneditor.min.css" type="text/css" media="all" rel="stylesheet">

To the top of the form.

Adding the django-json-widget to the admin interface does work without any adjustments. Does anyone have a fix that lets you use the normally included jsoneditor files in forms?

1reaction
jsmedmarcommented, Sep 22, 2019

As for now, I managed to fix it with this:

from django_json_widget.widgets import JSONEditorWidget


class CustomJSONEditorWidget(JSONEditorWidget):
    # hardcode media until this issue gets resolved
    # https://github.com/jmrivas86/django-json-widget/issues/27
    class Media:
        extend = False
        css = {
            "all": (
                "https://cdnjs.cloudflare.com/ajax/libs/"
                "jsoneditor/7.0.4/jsoneditor.min.css",
                "https://cdnjs.cloudflare.com/ajax/libs/"
                "jsoneditor/7.0.4/img/jsoneditor-icons.svg",
            )
        }
        js = (  # pylint: disable=invalid-name
            "https://cdnjs.cloudflare.com/ajax/libs/"
            "jsoneditor/7.0.4/jsoneditor.min.js",
        )
Read more comments on GitHub >

github_iconTop Results From Across the Web

ReferenceError:Can't find variable:weatherCondition
I get the error "ReferenceError:Can't find variable:weatherCondition".And if I take only temperature variable I get the same error ...
Read more >
ReactNativeJS: ReferenceError: Can't find variable: error #1004
Describe the bug Using transform-remove-console triggers ReactNativeJS: ReferenceError: Can't find variable: error only on production build ...
Read more >
Swagger UI tutorial | Documenting APIs - Idratherbewriting.com
Opened the error console and there is a complaint about "ReferenceError: Can't find variable: JSONEditor" which I think is stopping ...
Read more >
ReferenceError: Can't find variable: asdf : r/reactnative - Reddit
It doesn't like it. I'm trying to use two state variables. edit: this.setState({currentWord: this.state.asdf}).
Read more >
@json-editor/json-editor | Yarn - Package Manager
Important: This documentation covers modern versions of Yarn. For 1.x docs, see classic.yarnpkg.com. Yarn.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found