June 2018
Beginner
508 pages
13h 8m
English
We need to write three views. We need one for the home page, one to display the list of all entries for a user, and one to create a new entry. We also need views to log in and log out. But thanks to Django, we don't need to write them. I'll paste the code in steps:
# entries/views.pyimport refrom django.contrib.auth.decorators import login_requiredfrom django.contrib.messages.views import SuccessMessageMixinfrom django.urls import reverse_lazyfrom django.utils.decorators import method_decoratorfrom django.views.generic import FormView, TemplateViewfrom .forms import EntryFormfrom .models import Entry
Let's start with the imports. We need the re module to handle regular expressions, then we need a few classes and functions ...
Read now
Unlock full access