From the course: Django Essential Training

Unlock this course with a free trial

Join today to access over 24,900 courses taught by industry experts.

Template for update

Template for update

- [Instructor] Every node now has the user that created it, but our endpoint is still displaying all the notes from all the users. We also didn't add any authentication. So in order to keep privacy, we need to fix that. So let's go back here on the notes, views dot pi, and import from django dot contrib dot auth dot mixins (indistinct) import, login required mixin. Then on the list view, we need to add the login require mixin, and don't forget, oops, required mixin. And let's not forget to add the login URL. So for now, this is going to be the admin. This login URL means that if a user tried to access the list view, and it's not logged in, they will be redirected to the slash admin instead of seeing a 404. Okay, so now what we need is to change the query so we can only display the queries of the logged in user. But where is the query? (chuckling) As we discussed earlier, class-based views are highly powerful, and yet highly changeable. We can use a documentation website to check for…

Contents