def profile_create(request): form = ProfileForm(request.POST) if form.is_valid(): form.save() return redirect('index') else: return render(request, 'home-no-profile.html')
def delete_profile(request): profile = get_profile() if request.method == 'GET': context = {'form': ProfileForm(instance=profile)} return render(request, 'profile-delete.html', context) else: profile.delete() [expense.delete() for expense in Expense.objects.all()] return redirect('index')
def delete_profile(request): profile = get_profile() if request.method == 'GET': context = { 'form': ProfileForm(instance=profile), } return render(request, 'profile-delete.html', context) else: profile.delete() return redirect('index')
def create_profile(request): if request.method == 'GET': context = { 'form': ProfileForm() } return render(request, 'home-no-profile.html', context) else: form = ProfileForm(request.POST) if form.is_valid(): form.save() return redirect('index') context = { 'form': ProfileForm() } return render(request, 'home-no-profile.html', context)
def create_profile(request): if request.method == "GET": context = { "form": ProfileForm(), } return render(request, "home-no-profile.html", context) else: form = ProfileForm(request.POST) if form.is_valid(): form.save() return redirect("index") context = { "form": form, } return render(request, "home-no-profile.html", context)
def edit_profile(request): profile = get_profile() if request.method == 'GET': context = {'form': ProfileForm(instance=profile)} return render(request, 'profile-edit.html', context) else: form = ProfileForm(request.POST, instance=profile) if form.is_valid(): form.save() return redirect('profile index') context = { 'form': form, } return render(request, 'profile-edit.html', context)
def profile_edit(request): profile = Profile.objects.all()[0] if request.method == 'GET': context = { 'form': ProfileForm(instance=profile), } return render(request, 'profile-edit.html', context) else: form = ProfileForm(request.POST, instance=profile) if form.is_valid(): form.save() return redirect('profile index') context = { 'form': form, } return render(request, 'profile-edit.html', context)
def create_profile(request): if request.method == 'GET': context = { 'form': ProfileForm(), } return render(request, 'home-no-profile.html', context) else: form = ProfileForm(request.POST) if form.is_valid(): form.save() return redirect( 'home page' ) # home page => index (template 'home_with_profile.html) context = { 'form': form, } return render(request, 'home-no-profile.html', context)
def edit_profile(request): profile = Profile.objects.all()[0] if request.method == "GET": context = { "form": ProfileForm(instance=profile), } return render(request, "profile-edit.html", context) else: form = ProfileForm(request.POST, instance=profile) if form.is_valid(): form.save() return redirect("index profile") context = { "form": form, } return render(request, "profile-edit.html", context)