django makes it easy to restrict access to pagesbut you have to decide which pages to protect it' better to think about which pages need to be unrestricted first and then restrict all the other pages in the project you can easily correct overrestricting accessand it' less dangerous than leaving sensitive pages unrestricted in learning logwe'll keep the home pagethe registration pageand logout unrestricted we'll restrict access to every other page here' learning_logs/views py with @login_required decorators applied to every view except index()views py --snip-@login_required def topics(request)--snip-@login_required def topic(requesttopic_id)--snip-@login_required def new_topic(request)--snip-@login_required def new_entry(requesttopic_id)--snip-@login_required def edit_entry(requestentry_id)--snip-try accessing each of these pages while logged outyou'll be redirected back to the login page you'll also be unable to click links to pages such as new_topic but if you enter the url redirected to the login page you should restrict access to any url that' publicly accessible and relates to private user data connecting data to certain users now we need to connect the data submitted to the user who submitted it we need to connect only the data highest in the hierarchy to userand the lower-level data will follow for examplein learning logtopics are the highest level of data in the appand all entries are connected to topic as long as each topic belongs to specific userwe'll be able to trace the ownership of each entry in the database we'll modify the topic model by adding foreign key relationship to user we'll then have to migrate the database finallywe'll have to modify some of the views so they only show the data associated with the currently logged-in user