Open omgitskuei opened 3 years ago
Hi @omgitskuei
As explained in tutorial extension Homework: Adding security to your website, section Authorizing add/edit of posts, you'll have to import that decorator with
from django.contrib.auth.decorators import login_required
Put that import ...
line in the top section of each Python file, in which you want to use the @login_required
decorator.
Does the error still occur if you do that?
Hi Django Girls, thank you this fixes the NameError. It would be helpful to have this import instruction in the Add Approve/Delete Comments section of your Extensions book. The sections didn't look like they needed to be read in order.
It would be helpful to have this import instruction in the Add Approve/Delete Comments section of your Extensions book.
:+1: Good point.
The sections didn't look like they needed to be read in order.
AFAIK, they indeed aren't intended to have to be read in order.
Can you make a pull request with that addition? You can find the source file for that section in this repository here at en/homework_create_more_models
.
Hi, after I add @login_required to functions comment_approve and comment_remove in views.py, I'm getting nameError in the CMD saying "login_required" is not defined.