@login_required
@require_http_methods(['GET', 'POST'])
@mobile_template('users/{mobile/}')
def change_email(request, template):
 if (request.method == 'POST'):
  form = EmailChangeForm(request.user, request.POST)
  u = request.user
  if (form.is_valid() and (u.email != form.cleaned_data['email'])):
   EmailChange.objects.filter(user=request.user).delete()
   email_change = EmailChange.objects.create_profile(user=request.user, email=form.cleaned_data['email'])
   EmailChange.objects.send_confirmation_email(email_change, form.cleaned_data['email'])
   return render(request, (template + 'change_email_done.html'), {'email': form.cleaned_data['email']})
 else:
  form = EmailChangeForm(request.user, initial={'email': request.user.email})
 return render(request, (template + 'change_email.html'), {'form': form})

@ login_required @ require_http_methods ( [ 'GET' , 'POST' ] ) @ mobile_template ( 'users/{mobile/}' ) def change_email ( request , template ) : if ( request . method == 'POST' ) : form = EmailChangeForm ( request . user , request . POST ) u = request . user if ( form . is_valid ( ) and ( u . email != form . cleaned_data [ 'email' ] ) ) : EmailChange . objects . filter ( user = request . user ) . delete ( ) email_change = EmailChange . objects . create_profile ( user = request . user , email = form . cleaned_data [ 'email' ] ) EmailChange . objects . send_confirmation_email ( email_change , form . cleaned_data [ 'email' ] ) return render ( request , ( template + 'change_email_done.html' ) , { 'email' : form . cleaned_data [ 'email' ] } ) else : form = EmailChangeForm ( request . user , initial = { 'email' : request . user . email } ) return render ( request , ( template + 'change_email.html' ) , { 'form' : form } )
change users email .