def regenerate_api_key(request): form = forms.RegenerateApiKeyForm(request.POST) if form.is_valid(): key, is_new = models.ApiKey.objects.get_or_create(user=request.user) key.regenerate() key.save() return redirect('kb-account-main')
def regenerate_api_key(request): form = forms.RegenerateApiKeyForm(request.POST) if form.is_valid(): profile = request.user.get_profile() profile.api_secret = apikey.ApiKey.NewSecret() profile.save() return redirect_to(request, url='/account')