swampdragon how to import js file?

181 views Asked by At

I'm following the swampdragon tutorial. I've finish it, copy and paste everythings, but when I'm on http://localhost:8000/, I got this error in the javascript console.

GET http://localhost:8000/swampdragon/js/dist/datamapper.js 
GET http://localhost:8000/swampdragon/js/angular/services.js 
GET http://localhost:8000/controllers.js 
GET http://localhost:8000/app.js 
angular.js:36Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.2.21/$injector/modulerr?p0=TodoApp&p1=Error%3…gleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.2.21%2Fangular.min.js%3A18%3A277)

Here is my settings:

STATIC_URL = '/static/'

# SwampDragon settings
SWAMP_DRAGON_CONNECTION = ('swampdragon.connections.sockjs_connection.DjangoSubscriberConnection', '/data')
TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')]
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]
DRAGON_URL = 'http://localhost:9999/'

And here my index.html:

{% load static swampdragon_tags %}
html code 
...
...
<!-- AngularJS -->
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.21/angular.min.js"></script>

{% swampdragon_settings %}
<script type="text/javascript" src="{% static 'swampdragon/js/dist/swampdragon.min.js' %}"></script>
<script type="text/javascript" src="{{ STATIC_URL }}swampdragon/js/dist/datamapper.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}swampdragon/js/angular/services.js"></script>

<!-- To-do app -->
<script type="text/javascript" src="{{ STATIC_URL }}app.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}controllers.js"></script>
1

There are 1 answers

0
BoumTAC On BEST ANSWER

So I got an answer on github, here is the solution. It was STATIC_URL.

{% swampdragon_settings %}
<script type="text/javascript" src="{% static 'swampdragon/js/dist/swampdragon.min.js' %}"></script>
<script type="text/javascript" src="{{ static }}swampdragon/js/dist/datamapper.js"></script>
<script type="text/javascript" src="{{ static }}swampdragon/js/angular/services.js"></script>

<!-- To-do app -->
<script type="text/javascript" src="{{ static }}app.js"></script>
<script type="text/javascript" src="{{ static }}controllers.js"></script>