Question

Is there a way to user dajaxice with django class based views? I'm trying this, but not having much success:

class FavoriteEnroledTrainee(SessionMixin, View):

    def get(self, request, *args, **kwargs):
        print 'here'

    @method_decorator(dajaxice_register(method='GET', name='company.favorite'))
    def dispatch(self, *args, **kwargs):
        return super(FavoriteEnroledTrainee, self).dispatch(*args, **kwargs)

I can see the dajaxice is able to fetch the view but nothing gets printed.

Was it helpful?

Solution

You cannot register the dispatch method, because it's not the view entry point. Dajaxice will try to call dispatch directly, but this won't work because it's not a fully functionnal view.

You should register the result of the *as_view* call :

class FavoriteEnroledTrainee(SessionMixin, View):
    def get(self, request, *args, **kwargs):
        print 'here'
favorite_enroled_trainee = dajaxice_register(method='GET', name='company.favorite')(FavoriteEnroledTrainee.as_view())
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top