post_publishviews so that only logged-in users can access them. Django ships with some nice helpers for doing that, called decorators. Don't worry about the technicalities now; you can read up on these later. The decorator we want to use is shipped in Django in the module
django.contrib.auth.decoratorsand is called
blog/views.pyand add these lines at the top along with the rest of the imports:
post_publishviews (decorating them) like the following:
http://127.0.0.1:8000/post/new/. Notice the difference?
If you just got the empty form, you are probably still logged in from the chapter on the admin-interface. Go to
http://127.0.0.1:8000/admin/logout/to log out, then go to
mysite/urls.pyadd a url
path('accounts/login/', views.LoginView.as_view(), name='login'). So the file should now look similar to this:
blog/templates/registrationand a file inside named
blog/templates/blog/base.htmland change it so the part between the
<body>tags looks like this:
mysite/urls.pypointing to Django's logout view (i.e.
django.contrib.auth.views.logout), like this: