[Answer]-What is the meaning of "@" above "def"?

1πŸ‘

βœ…

@ is used to decorate a function. This mechanism is called a decorator.

A decorator is a function that will modify the behavior of another function.

In your case, the require_http_methods decorator checks that the request is a GET or a POST method before calling the my_view function.

It’s a very powerful mechanism and I do recommend to spend a little time for understanding it. You can start with this tutorial

I hope it helps

πŸ‘€luc

Leave a comment