June 2018
Beginner
508 pages
13h 8m
English
The first view is HomeView:
# entries/views.pyclass HomeView(TemplateView): template_name = 'entries/home.html' @method_decorator( login_required(login_url=reverse_lazy('login'))) def get(self, request, *args, **kwargs): return super(HomeView, self).get(request, *args, **kwargs)
It inherits from TemplateView, which means that the response will be created by rendering a template with the context we'll create in the view. All we have to do is specify the template_name class attribute to point to the correct template. Django promotes code reuse to a point that if we didn't need to make this view accessible only to logged-in users, the first two lines would have been all we needed.
However, we want this view to be accessible only ...
Read now
Unlock full access