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 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 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 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)