I am terribly confused about the routing and url set up when using backbone.js and django together with the Django-restframework.
- 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(serializer.data, "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(); studentsView.render(); });
Yet the routes never actually get to my views?