What does a class followed by method does in Python
Question:
In Django urls there is this code:
path("login/", Login.as_view(), name="loggps")
Login
is a class and as_view()
is a method but is not in the Login
class, probably is in a Parent class.
What does Class.method
does in Python?
Answers:
I think as_view is a classmethod
class Login:
@classmethod
def as_view(self):
print("hi")
Login.as_view()
In Django urls there is this code:
path("login/", Login.as_view(), name="loggps")
Login
is a class and as_view()
is a method but is not in the Login
class, probably is in a Parent class.
What does Class.method
does in Python?
I think as_view is a classmethod
class Login:
@classmethod
def as_view(self):
print("hi")
Login.as_view()