Django makes it easy to restrict access to certain pages to logged-in users through the @login_required decorator. A decorator is a directive placed just before a function definition that Python applies to the function before it runs to alter how the function code behaves. Let’s look at an example.

