def invitation_retrieve(request, response_format='html'):
 if request.user.username:
  return HttpResponseRedirect('/')
 email = request.REQUEST.get('email', None)
 key = request.REQUEST.get('key', None)
 if (email and key):
  try:
   invitation = Invitation.objects.get(email=email, key=key)
  except:
   raise Http404
 else:
  raise Http404
 if request.POST:
  form = InvitationForm(invitation, request.POST)
  if form.is_valid():
   profile = form.save()
   username = profile.user.username
   password = form.cleaned_data['password']
   user = authenticate(username=username, password=password)
   if user:
    invitation.delete()
    login(request, user)
    return HttpResponseRedirect('/')
 else:
  form = InvitationForm(invitation)
 return render_to_response('core/invitation_retrieve', {'invitation': invitation, 'form': form}, context_instance=RequestContext(request), response_format=response_format)

def invitation_retrieve ( request , response_format = 'html' ) : if request . user . username : return HttpResponseRedirect ( '/' ) email = request . REQUEST . get ( 'email' , None ) key = request . REQUEST . get ( 'key' , None ) if ( email and key ) : try : invitation = Invitation . objects . get ( email = email , key = key ) except : raise Http404 else : raise Http404 if request . POST : form = InvitationForm ( invitation , request . POST ) if form . is_valid ( ) : profile = form . save ( ) username = profile . user . username password = form . cleaned_data [ 'password' ] user = authenticate ( username = username , password = password ) if user : invitation . delete ( ) login ( request , user ) return HttpResponseRedirect ( '/' ) else : form = InvitationForm ( invitation ) return render_to_response ( 'core/invitation_retrieve' , { 'invitation' : invitation , 'form' : form } , context_instance = RequestContext ( request ) , response_format = response_format )
retrieve invitation and create account .