windows 10 pro office 2019 pro office 365 pro windows 10 home windows 10 enterprise office 2019 home and business office 2016 pro windows 10 education visio 2019 microsoft project 2019 microsoft project 2016 visio professional 2016 windows server 2012 windows server 2016 windows server 2019 Betriebssysteme office software windows server instagram takipçi instagram beğeni instagram görüntüleme instagram otomatik beğeni facebook beğeni facebook sayfa beğenisi facebook takipçi twitter takipçi twitter beğeni twitter retweet youtube izlenme youtube abone instagram

Django-RestFramework 2 and backbone.js routing

Asked By: Anonymous

I am terribly confused about the routing and url set up when using backbone.js and django together with the Django-restframework.

  1. Where does the the template fit in when using a REST framework?

For example, i have a class based view defined for one of my urls where i want to use backbone.js to just update the div displaying students:

url(r'^home/students/$', views.StudentList.as_view()),

class StudentList(APIView):
    List all students
    def get(self, request, format=None):
        students = Person.objects.filter(person_type = Person.STUDENT)
        serializer = PersonSerializer(students)
        return Response(, "core/teachers/teacher_teaching.html")

    def pre_save(self, obj):
        obj.owner = self.request.user
  • How does Backbone routes fit in with the url routing of django. I have in a file router.js, something like this:
    function($,jqueryui, _, Backbone, HomeView, StudentsView) {
    var AppRouter = Backbone.Router.extend({
        routes: {
            // Define some URL routes
            ':home': 'showStudents',
            'users': 'showContributors',
            // Default
            '*actions': 'defaultAction'
    var initialize = function(){
        var app_router = new AppRouter;
        app_router.on('route:showStudents', function(){
            // Call render on the module we loaded in via the dependency array
            var studentsView = new StudentsView();

Yet the routes never actually get to my views?


Answered By: Anonymous

Where does the the template fit in when using a REST framework?

It doesn’t; Django templates are for normal Django HTML pages, not REST framework APIs. REST framework API responses are programmatically-generated documents (typically JSON or XML), so they don’t need templates.

How does Backbone routes fit in with the url routing of django

They are 100% completely separate. Let’s say you have a URL like:

Django will handle this much of that URL:

while Backbone will handle the remaining:


Of course, that assumes that Django returns a webpage that uses Backbone; if it doesn’t, the #baz will never even come in to play.

As a quick summary, when you visit a URL like the above, your browser will ask for /foo/bar. This is when your in Django comes in; it has:

url(r'^foo/bar/?$', views.FooBar.as_view()),

so your webserver knows to send back whatever views.FooBar.as_view() gives it (whether that is REST framework-produced JSON document or an old school Django HTML document).

Once that document comes back to the server, it renders it, and this is where client-side code like Backbone and its router take their turn. The Backbone Router (whenever you call Backbone.history.start()) looks at the URL (ie. window.location) and looks for the anchor or “hash” part of the URL (eg. #baz). It then compares that part of the URL to its route list (similar to how your webserver compared the earlier part to and if it finds a match, it “sends you to a page”.

It’s key to understand though, it doesn’t really send you anywhere at all; all its really doing is changing the hash part of the URL and then running some Javascript which manipulates the DOM. Therefore, it is impossible for the Backbone Router to ever send you to a Django URL; if you want to hit a server route, you need to either use AJAX or window.location =.

techinplanet staff

instagram volgers kopen volgers kopen buy windows 10 pro buy windows 11 pro

Windows 10 Kaufen Windows 10 Pro Office 2019 Kaufen Office 365 Lizenz Windows 10 Home Lizenz Office 2019 Home Business Kaufen windows office 365 satın al follower kaufen instagram follower kaufen porno
Alanya escort Manavgat escort Fethiye escort Kemer escort Didim escort Çanakkale escort Aydın escort Muğla escort Tekirdağ escort Manisa escort Balıkesir escort Trabzon escort Elazığ escort Ordu escort Kütahya escort Isparta escort Rize escort Kahramanmaraş escort Yalova escort Giresun escort Yozgat escort Tokat escort Şanlıurfa escort Sivas escort Batman escort Erzurum escort Sinop escort Kırşehir escort Karaman escort Kırıkkale escort Bolu escort Amasya escort Niğde escort Uşak escort Edirne escort Çorum escort Osmaniye escort Zonguldak escort Van escort Erzincan escort Söke escort Bodrum escort Çerkezköy escort Akhisar escort Bandırma escort Ayvacık escort Akçaabat escort Karakoçan escort Altınordu escort Tavşanlı escort Eğirdir escort Ardeşen escort Afşin escort Altınova escort Bulancak escort Sorgun escort Erbaa escort Viranşehir escort Zara escort Kozluk escort Aziziye escort Ayancık escort Kaman escort Ermenek escort Keskin escort Gerede escort Göynücek escort Bor escort Banaz escort Havsa escort Osmancık escort Bahçe escort Alaplı escort Başkale escort Kemah escort Nazilli escort Fethiye escort Çorlu escort Alaşehir escort Altıeylül escort Biga escort Araklı escort Kovancılar escort Fatsa escort Simav escort Yalvaç escort Çayeli escort Dulkadiroğlu escort Çiftlikköy escort Espiye escort Sarıkaya escort Niksar escort Suruç escort Yıldızeli escort Sason escort Horasan escort Boyabat escort Mucur escort Sarıveliler escort Yahşihan escort Göynük escort Gümüşhacıköy escort Çamardı escort Eşme escort İpsala escort Sungurlu escort Hasanbeyli escort Çaycuma escort İpekyolu escort Refahiye escort Kuşadası escort Marmaris escort Süleymanpaşa escort Turgutlu escort Susurluk escort Gelibolu escort Of escort Ünye escort Domaniç escort Fındıklı escort Elbistan escort Çınarcık escort Tirebolu escort Akdağmadeni escort Turhal escort Eyyübiye escort Suşehri escort Yakutiye escort Gerze escort Mengen escort Merzifon escort Ulukışla escort Sivaslı escort Keşan escort Kadirli escort Ereğli escort Özalp escort Tercan escort Efeler escort Didim escort Çine escort Dalaman escort Menteşe escort Milas escort Ortaca escort Seydikemer escort Ergene escort Kapaklı escort Malkara escort Salihli escort Şehzadeler escort Soma escort Yunusemre escort Ayvalık escort Bigadiç escort Burhaniye escort Gönen escort Karesi escort Çan escort Yenice escort Ortahisar escort Yomra escort Perşembe escort Pazar escort Onikişubat escort Pazarcık escort Türkoğlu escort Eynesil escort Görele escort Piraziz escort Yağlıdere escort Çayıralan escort Boğazlıyan escort Zile escort Siverek escort Karaköprü escort Haliliye escort Akçakale escort Şarkışla escort Gemerek escort Oltu escort Palandöken escort Mudurnu escort Suluova escort Taşova escort Toprakkale escort Kilimli escort Tuşba escort Üzümlü escort