python - Django: Get request in base class -


i have base class extending object , trying access self.request.session throwing error saying request doesn't exist.

class basetemplateview(object):  def __init__(self,  *args, **kwargs):      try:          if self.request.session.get('sessiontoken', none) == none:             raise valueerror("user not logged in")           register(application_id, rest_api_key, session_token=token)         self.user = user.current_user()         self.loggedin = true         print("success")     except:         print("failed")         self.user = none         self.loggedin = false     print("called init")  class indexview(basetemplateview, templateview):       template_name = "dashboard.html" 

please help

no, request not exist @ point logic should go in dispatch method.


Comments