@login_required
@require_http_methods(['GET', 'POST'])
@mobile_template('users/{mobile/}edit_settings.html')
def edit_settings(request, template):
 if (request.method == 'POST'):
  form = SettingsForm(request.POST)
  if form.is_valid():
   form.save_for_user(request.user)
   messages.add_message(request, messages.INFO, _(u'Your settings have been saved.'))
   return HttpResponseRedirect(reverse('users.edit_settings'))
  return render(request, template, {'form': form})
 values = request.user.settings.values()
 initial = dict()
 for v in values:
  try:
   initial[v['name']] = literal_eval(v['value'])
  except (SyntaxError, ValueError):
   initial[v['name']] = v['value']
 form = SettingsForm(initial=initial)
 return render(request, template, {'form': form})

@ login_required @ require_http_methods ( [ 'GET' , 'POST' ] ) @ mobile_template ( 'users/{mobile/}edit_settings.html' ) def edit_settings ( request , template ) : if ( request . method == 'POST' ) : form = SettingsForm ( request . POST ) if form . is_valid ( ) : form . save_for_user ( request . user ) messages . add_message ( request , messages . INFO , _ ( u'Your settings have been saved.' ) ) return HttpResponseRedirect ( reverse ( 'users.edit_settings' ) ) return render ( request , template , { 'form' : form } ) values = request . user . settings . values ( ) initial = dict ( ) for v in values : try : initial [ v [ 'name' ] ] = literal_eval ( v [ 'value' ] ) except ( SyntaxError , ValueError ) : initial [ v [ 'name' ] ] = v [ 'value' ] form = SettingsForm ( initial = initial ) return render ( request , template , { 'form' : form } )
edit user settings .