Пример #1
0
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')
Пример #2
0
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)
Пример #3
0
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)
Пример #4
0
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)
Пример #5
0
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)
Пример #6
0
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)