I'm attempting to subclass the LoginView so that I can change the template_name that is part of LoginView. I've simplified my template_file_name function for the purposes of this example.
def template_file_name(request, template_name, page_title):
return template_name
class CustomLoginView(LoginView):
template_name = template_file_name(self.request, 'login.html', "Login")
I'm getting this error:
NameError: name 'self' is not defined
Thanks!
CodePudding user response:
Override the get_template_names
method instead. You don't have access to self when the class is being created
class CustomLoginView(LoginView):
def get_template_names(self):
return template_file_name(self.request, 'login.html', "Login")