Reputation: 3408
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.
Upvotes: 2
Views: 287
Reputation: 111
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())
Upvotes: 3