As you had seen the web page can be accessed by anyone visiting the url. In some cases, you won't like that to happen. You can restrict the access to a web page by using the @login_required decorator, before the function.
It can be done as follows :
from django.contrib.auth.decorators import login_required
@login_required
def home(request):
return render(request, 'home.html')
Now, if you try to visit the page, it would show something like this.
This is because DEBUG is set to True in the settings.py file. If you set debug to False , then a page like this would be displayed.
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
# When DEBUG is set to False, the hosts needs to be specified on which the website should be loaded.
# * specifies that it can loaded on all hosts
ALLOWED_HOSTS = ['*']
When DEBUG is set to False, the hosts needs to be specified on which the website should be loaded. '*' specifies that it can loaded on all hosts.
You can set DEBUG to True again for the tutorial.