the following code provides the url pattern for the registration pageagain in users/urls pyurls py --snip-urlpatterns login page --snip-registration page url( '^register/$'views registername='register')this pattern matches the url sends requests to the register(function we're about to write the register(view function the register(view function needs to display blank registration form when the registration page is first requested and then process completed registration forms when they're submitted when registration is successfulthe function also needs to log in the new user add the following code to users/views pyviews py from django shortcuts import render from django http import httpresponseredirect from django core urlresolvers import reverse from django contrib auth import loginlogoutauthenticate from django contrib auth forms import usercreationform def logout_view(request)--snip-def register(request)"""register new user ""if request method !'post'display blank registration form form usercreationform(elseprocess completed form form usercreationform(data=request postw if form is_valid()new_user form save(log the user in and then redirect to home page authenticated_user authenticate(username=new_user usernamepassword=request post['password ']login(requestauthenticated_userreturn httpresponseredirect(reverse('learning_logs:index')context {'form'formreturn render(request'users/register html'context