Django function declaration question.

Asked 2 years ago, Updated 2 years ago, 138 views

In the Django tutorial, functions in the views file receive requests without receiving self as the first parameter. I know that the Python function must receive self as the first parameter I wonder what the difference is %%

django python function

2022-09-22 21:53

1 Answers

If you use a class in Python, the member function in the class must first use self, which means itself, as the parameter. (Exception is that a class function, for example, has the characteristics of a static function in java.)

If you do not use the class, there are no rules for the first factor.

Perhaps the views in the tutorial defined a function for the view without using the class.


2022-09-22 21:53

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.