Search code examples
javascriptdjangocoffeescriptchaplinjs

Using ChaplinJS in Django project


I'm trying to build ChaplinJS in Django project. I've downloaded Chaplin Boilerplate and opened index.html in browser. Worked perfectly fine (showed chaplin example page). Then i put all files into Django project "front-end" dir and resolved all paths to *.js libs in index.html via django's staticfiles. When i open my page from localhost now i'm getting just empty screen. Server console shows:

[11/Jun/2015 21:34:53]"GET /books/ HTTP/1.1" 200 1542
[11/Jun/2015 21:34:53]"GET /front-end/books/bower_components/requirejs/require.js/ HTTP/1.1" 200 82687
[11/Jun/2015 21:34:53]"GET /front-end/books/js/routes.js HTTP/1.1" 200 185
[11/Jun/2015 21:34:53]"GET /front-end/books/js/application.js HTTP/1.1" 200 802
[11/Jun/2015 21:34:54]"GET /front-end/books/bower_components/chaplin/chaplin.js HTTP/1.1" 200 90223
[11/Jun/2015 21:34:54]"GET /front-end/books/bower_components/jquery/jquery.js HTTP/1.1" 200 242142
[11/Jun/2015 21:34:54]"GET /front-end/books/bower_components/lodash/dist/lodash.js HTTP/1.1" 200 229855
[11/Jun/2015 21:34:54]"GET /front-end/books/bower_components/backbone/backbone.js HTTP/1.1" 200 60127

Also i checked JS console in browser: Application object is created, but none Controllers or Views. What am i doing wrong?


Solution

  • Found my mistake. Everything was fine except URL. In Django project i had books application, so URL to index page was localhost:8000/books/ but in Chaplin routes match was set on match '', 'hello#show' so changing it to match 'books', 'hello#show' solves the problem