I am trying to convert some of my django views from function based views to class based views, and I ran into a little problem.
My OO is a little weak, and I think the problem is that I lost information about where things are going.
I have a custom decoration decoder that I need on presentations, so I have ...
First I have a view class from this example
http://www.djangosnippets.org/snippets/760/
Then my view class looks like this:
class TopSecretPage(View):
@custom_login
def __call__(self, request, **kwargs):
pass
The problem is that my decorator cannot receive the request.session request for some reason ...
My decorator looks like this ...
def myuser_login_required(f):
def wrap(request, *args, **kwargs):
if 'field' not in request.session.keys():
return wrap
I think it is simple that I will miss, thanks for your patience!
UPDATE:
, , ...
"ViewDoesNotExist: TopSecretPage projectname.application.views. : type object 'TopSecretPage' 'session' '
, ....
def myuser_login_required(request, *args, **kwargs):
if 'username' not in request.session.keys():
return HttpResponseRedirect(reverse("login-page"))
return True