from django http import httpresponseredirect from django core urlresolvers import reverse from django contrib auth import logout def logout_view(request)"""log the user out "" logout(requestw return httpresponseredirect(reverse('learning_logs:index')we import the logout(function from django contrib auth in the functionwe call logout(vwhich requires the request object as an argument we then redirect to the home page linking to the logout view now we need logout link we'll include it as part of base html so it' available on every page and include it in the {if user is_authenticated %portion so only users who are already logged in can see itbase html --snip-{if user is_authenticated %hello{user username }log out {else %log in {endif %--snip-figure - shows the current home page as it appears to logged-in user the styling is minimal because we're focusing on building site that works properly when the required set of features workswe'll style the site to look more professional figure - the home page with personalized greeting and logout link the registration page nextwe'll build page to allow new users to register we'll use django' default usercreationform but write our own view function and template user accounts