Jinto Antony
Jinto Antony

Reputation: 468

Access class based view from a method

I have a class based view in a model. And I want to access it from a view method.

class GetAjaxViewUser():


def dispatch(self, request, *args, **kwargs):

    return super().dispatch(request, *args, **kwargs)

And this is in a model. And, I want to access it from a view method, something like this:

def AjaxView(request):

    return GetAjaxViewUser.as_view()

Upvotes: 0

Views: 90

Answers (1)

BugHunter
BugHunter

Reputation: 1204

You can access cbv from another method like

return GetAjaxViewUser.as_view()(request)

But I wonder what would you want to achieve by this?

Upvotes: 2

Related Questions