@anonymous_csrf
@mobile_template('users/{mobile/}forgot_username.html')
def forgot_username(request, template):
 if (request.method == 'POST'):
  form = ForgotUsernameForm(request.POST)
  was_valid = form.is_valid()
  if was_valid:
   try_send_email_with_form(form.save, form, 'email', use_https=request.is_secure())
  if (form.is_valid() or (not was_valid)):
   messages.add_message(request, messages.INFO, _(u"We've sent an email with the username to any account using {email}.").format(email=form.data['email']))
   return HttpResponseRedirect(reverse('users.login'))
 else:
  form = ForgotUsernameForm()
 return render(request, template, {'form': form})

@ anonymous_csrf @ mobile_template ( 'users/{mobile/}forgot_username.html' ) def forgot_username ( request , template ) : if ( request . method == 'POST' ) : form = ForgotUsernameForm ( request . POST ) was_valid = form . is_valid ( ) if was_valid : try_send_email_with_form ( form . save , form , 'email' , use_https = request . is_secure ( ) ) if ( form . is_valid ( ) or ( not was_valid ) ) : messages . add_message ( request , messages . INFO , _ ( u"We've sent an email with the username to any account using {email}." ) . format ( email = form . data [ 'email' ] ) ) return HttpResponseRedirect ( reverse ( 'users.login' ) ) else : form = ForgotUsernameForm ( ) return render ( request , template , { 'form' : form } )
look up a username based on an email address .